Why isn't my matrix correct?

7 ビュー (過去 30 日間)
Jenny Andersen
Jenny Andersen 2019 年 12 月 30 日
編集済み: KALYAN ACHARJYA 2019 年 12 月 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)

採用された回答

KALYAN ACHARJYA
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
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 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by