Why isn't my matrix correct?
7 ビュー (過去 30 日間)
古いコメントを表示
So I am trying to solve for x in Mx = d, but I only get a 3*2 matrix. I should get a 3*3 matrix. What am I doing wrong?
A = [1 0; 2 2; 4 3; 5 4]
b = [0;2;5;7]
M = A.' *A;
d = A.' *b;
x = A\b;
disp(x)
0 件のコメント
採用された回答
KALYAN ACHARJYA
2019 年 12 月 30 日
編集済み: KALYAN ACHARJYA
2019 年 12 月 30 日
You are trying to solve x, Ax=b, where A and b is given (There is no role of M and D as per your code)
A = [1 0; 2 2; 4 3; 5 4]
b = [0;2;5;7]
x = A\b;
disp(x)
The solution is
0.5000
1.0000
Please note in this case, the A is non invertible, in such case please do read this thread In Ax=bAx=b. If AA is not invertible there are no solutions or infinity. How to determine what the case is?
Now you can verify the solution through manual also by creating agumented matrix, thereafter row echelon form or using Matlab also. Here is the very simple article (2nd page) of those steps
>> result=[A,b] % Agumented matrix
result =
1 0 0
2 2 2
4 3 5
5 4 7
>> rref(result) % Row echelon form
ans =
1 0 0
0 1 0
0 0 1
0 0 0
There after please go to find a solution just a combination of pivot columns. Please, firstly go for Maths undesranding, then only proceed towards Matlab.
Hope it helps!
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!