Solve matrix problem with 10 unkowns
2 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
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
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);
See Also
Categories
Find more on Logical 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!