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