Solve matrix problem with 10 unkowns

2 views (last 30 days)
Sindre
Sindre on 24 Mar 2014
Edited: Matt J on 24 Mar 2014
Hi,
I got 10 equations and 10 unknows, so it should be easily solveable, but I don't know how to do it in Matlab.
The expression is: [K]*[h]=[Q] Where: [K]= A 10x10 matrix where everything is known [h]= A 10x1 matrix where 8 values are unknown and 2 are known [Q]= A 10x1 matrix where 2 values are unknown and 8 are known
How can you solve this in Matlab?

Answers (1)

Matt J
Matt J on 24 Mar 2014
Edited: Matt J on 24 Mar 2014
You have 10 linear equations in 4 unknowns. You can therefore rearrange your equations in the matrix form
A*x=b
where A is 10x4, b is 10x1, and x is a 4x1 vector of unknonws. Then you can solve as
x=A\b
However, because you have more equations than unknowns it is possible/likely that not all 10 equations will be simultaneously satisfied, but rather you will get a least squares solution.
  2 Comments
Sindre
Sindre on 24 Mar 2014
No, I have 10 unknowns. 8 unknowns in the h matrix and 2 unknowns in the Q matrix.
If all the unknown where in e.g. [h] I could just do [h]=[Q]/[K], but since I have unknowns in [h] and [Q] I have no idea how to write it.
How do I make the matrixes with unknowns? And how do I solve it when I have implemented all the matrixes in my script?
Matt J
Matt J on 24 Mar 2014
Edited: Matt J on 24 Mar 2014
If you write the equations in scalar form, it should be a simple matter of rearranging the equations so that all the unknowns, with their coefficients, are on the left hand side and all known constants are on the right hand side. Then you can express the re-arranged equation in matrix/vector form.
You can do this in a vectorized way if you have logical index vectors i and j such that h(i) and Q(j) are the unknowns:
I=eye(length(Q));
A=[K(:,i), -I(:,j)];
b=I(:,~j)*Q(~j)-K(:,~i)*h(~i);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!