Linsolve doesn't find solution to overdetermined system
古いコメントを表示
Matlab solves the following system correctly:
syms x y z A B C D E
eqn1 = 3*x + 1*y - 1*z == A;
eqn2 = 2*x - 2*y + 4*z == B;
eqn3 = -1*x + 0.5*y - 1*z == C;
%eqn4 = 2*x + 1*y + 0*z == D;
[AA,BB] = equationsToMatrix([eqn1, eqn2, eqn3], [x, y, z]);
X = linsolve(AA,BB);
solution:
- B/2 - 2*C
2*A + 4*B + 14*C
A + (5*B)/2 + 8*C
However if you add that 4th equation it will return:
Warning: Solution does not exist because the system is inconsistent.
That's not actually true? The solution should stay the same with the additional constraint that : D = 2 A + 3 B + 10 C
You can get it to work in Matlab if you ask it to solve for D as well:
[AA,BB] = equationsToMatrix([eqn1, eqn2, eqn3], [x, y, z, D]);
X = linsolve(AA,BB);
solution:
- B/2 - 2*C
2*A + 4*B + 14*C
A + (5*B)/2 + 8*C
2*A + 3*B + 10*C
But It does not work if you ask it to solve for all the variables:
[AA,BB] = equationsToMatrix([eqn1, eqn2, eqn3], [x, y, z, A, B, C, D]);
X = linsolve(AA,BB);
It will say that the solution is not unique because the matrix is rank deficient. That's not tue? The solution is still fully unique with that same one extra constraint D = 2 A + 3 B + 10 C. Solving it in terms of D also fully solves it in terms of A, B, C.
What is going on here? Is it that the solver always needs to solve for the same amount of variables as the rank of the matrix?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Stability Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!