Why isn't my matrix correct?

10 views (last 30 days)
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)

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 30 Dec 2019
Edited: KALYAN ACHARJYA on 30 Dec 2019
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!

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!