Why isn't my matrix correct?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jenny Andersen
el 30 de Dic. de 2019
Editada: KALYAN ACHARJYA
el 30 de Dic. de 2019
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 comentarios
Respuesta aceptada
KALYAN ACHARJYA
el 30 de Dic. de 2019
Editada: KALYAN ACHARJYA
el 30 de Dic. de 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
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 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!