Solve matrix problem with 10 unkowns

3 次查看(过去 30 天)
Sindre
Sindre 2014-3-24
编辑: Matt J 2014-3-24
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?

回答(1 个)

Matt J
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 个评论
Sindre
Sindre 2014-3-24
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 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 CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by