Solve matrix problem with 10 unkowns
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Matt J
2014-3-24
编辑:Matt J
2014-3-24
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 个评论
Matt J
2014-3-24
编辑:Matt J
2014-3-24
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);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!