Why linsolve cannot solve this very simple equation?
9 ビュー (過去 30 日間)
古いコメントを表示
A = [4,2,2; 5,1,3; 6,0,4];
B = [60; 70; 80];
X = linsolve(A,B)
The solution should be 6, 7, 11, since:
4x6 + 2x7 + 2x11 = 60
5x6 + 1x7 + 3x11 = 70
6x6 + 0x7 + 4x11 = 80
But I get the following answer:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.401487e-18.
X = [0; 10; 20]
Why?
0 件のコメント
採用された回答
Stephan
2021 年 4 月 19 日
編集済み: Stephan
2021 年 4 月 19 日
To solve this, the rank should be 3. Row 1 and 3 are not linear independent.
A = [4,2,2; 5,1,3; 6,0,4]
B = [60; 70; 80];
r1 = rank(A)
r2 = rank([A, B])
linsolve gives a correct solution, because there are more then 1 solutions, due to the rank:
>> X = linsolve(A,B)
Test = A*X
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
7.401487e-18.
X =
0
10
20
Test =
60
70
80
0 件のコメント
その他の回答 (1 件)
Steven Lord
2021 年 4 月 19 日
The vector [6; 7; 11] is a solution to the problem but it is not the only solution.
A = [4,2,2; 5,1,3; 6,0,4];
B = [60; 70; 80];
sol1 = [6; 7; 11];
check = A*sol1-B; % should be close to 0
[sol1, check]
N = null(A); % A*N is close to the 0 vector
sol2 = sol1 + N; % Since A*sol1 = B and A*N = 0, A*(sol1+N) = B+0 = B
check2 = A*sol2-B; % should also be close to 0
[sol2, check2]
sol3 = sol1 + 42*N; % A*(sol1+42*N) = A*sol1 + 42*A*N = B+0 = B
[sol3, A*sol3-B] % Also close to 0
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Stochastic Differential Equation (SDE) Models についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!