Clear Filters
Clear Filters

Finding unknow of equation

2 views (last 30 days)
Tasrif Ul
Tasrif Ul on 16 Nov 2022
Answered: John D'Errico on 16 Nov 2022
I have a A= 6*6 matrices with all known value, B=[0;0;x;0;0;y] and C=[a;b;0;c;d;-2000] and the relation is A*B=C. How can i get the unknown values of B &C?

Answers (2)

Abderrahim. B
Abderrahim. B on 16 Nov 2022
Hi!
Matrix A is also unknown for us ^^ !
Workflow to find the unknowns is as follow:
  1. Derive equations A*B = C
  2. Create symbolic variables, in your case :
syms x y a b c d
3. Declare the system of equations.
4. Solve System of Linear Equations Using solve
Please refer to this to learn further about how to solve system of linear equations.
Hope this helps

John D'Errico
John D'Errico on 16 Nov 2022
I'll use syms here, because it displays things nicely.
syms x y a b c d
B=[0;0;x;0;0;y]
B = 
C=[a;b;0;c;d;-2000]
C = 
So B and C are VECTORS, not matrices. Now you have a matrix A, that is 6x6, and is completely known. As long as A is entirely known and is of full rank, you can use any number of ways to solve the problem.
For example, you could just use solve. But solve will often be slow. It is trivial to accomplish though. As an example, I need to have the matrix A, in numerical form.
A = randi(9,[6,6])
A = 6×6
4 4 8 7 6 8 3 4 7 7 3 2 8 2 7 8 6 8 4 9 7 1 5 5 7 4 9 7 4 2 5 1 5 2 1 3
And now the solution using solve, for this particular matrix:
sol = solve(A*B == C,[a,b,c,d,x,y])
sol = struct with fields:
a: -16000/19 b: -84000/19 c: -42000/19 d: -116000/19 x: -16000/19 y: 14000/19
As easy, we can use equationsToMatrix to write the probmel in terms of linear algebra.
[S,T] = equationsToMatrix(A*B == C,[a,b,c,d,x,y])
S = 
T = 
So, for that particular matrix A, we now have two matrices, S and T that represnet the linear system. SOlve them, using backslash.
abcdxy = double(S)\double(T)
abcdxy = 6×1
1.0e+03 * -0.8421 -4.4211 -2.2105 -6.1053 -0.8421 0.7368
As you can see with format rat, the solution is the same.
format rat
abcdxy
abcdxy =
-16000/19 -84000/19 -42000/19 -116000/19 -16000/19 14000/19
Could we have done it differently yet? Yes. Move the unknowns to the left hand side, and move everything known to the right hand side. You will still have a system of linear equations. The result will be the same.

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!