Matrix does not want to multiply and gives an error when I multiply a 3x3 matrix with a 3x1 matrix
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
A=[9,29.3, 140.99; 29.3, 140.99,827.693; 140.99, 827.693, 5400.863]
Ainv=inv(A); % inverse matrix
B=[4.6;-16; -267.29] % B matrix used in A^-1*B
values = B * Ainv %multiply the matrix to get a and b
the multiplication does not want to multiply
1 comentario
Steven Lord
el 16 de Mayo de 2024
There's no need to call inv here and multiply. Yes, I know that's probably what you were taught in school, but to use A to solve a system of equations A*x = b compute x = A\b instead.
format longg
A=[9,29.3, 140.99; 29.3, 140.99,827.693; 140.99, 827.693, 5400.863]
B=[4.6;-16; -267.29]
values = A\B
checkThatAxEqualsB = A*values-B % Should contain values very close to 0
Respuestas (4)
Voss
el 8 de Mayo de 2024
Do Ainv*B not B*Ainv
A=[9,29.3, 140.99; 29.3, 140.99,827.693; 140.99, 827.693, 5400.863]
Ainv=inv(A) % inverse matrix
B=[4.6;-16; -267.29] % B matrix used in A^-1*B
values = Ainv*B %multiply the matrix to get a and b
0 comentarios
sai charan sampara
el 8 de Mayo de 2024
Editada: sai charan sampara
el 8 de Mayo de 2024
Hello Gihahn,
In line 2 "mat1" is not defined. If you want to have the inverse of "A" replace it with A. Also the size of "B" is 3x1 and "A" is 3x3 matrix. So trying to multiply "B" with "A" will give an error. You can take the transpose of "B" and then multiply with "A" or change the order of multiplication for the dimensions to agree for multiplication.
A=[9,29.3, 140.99; 29.3, 140.99,827.693; 140.99, 827.693, 5400.863]
Ainv=inv(A); % inverse matrix
B=[4.6;-16; -267.29] % B matrix used in A^-1*B
values = B' * Ainv
values = Ainv*B
0 comentarios
Ahmed Abed
el 16 de Mayo de 2024
You are multiplying [3x1] matrix by [3x3] one, which is mathmatically incorrect.
If you try values = Ainv*B then you will get an answer (not sure if it is what you wanting).
0 comentarios
Stephen23
el 16 de Mayo de 2024
Read the INV documentation! And then use the recommended function MLDIVIDE:
A = [9, 29.3, 140.99; 29.3, 140.99,827.693; 140.99, 827.693, 5400.863];
B = [4.6; -16; -267.29]
C = A\B
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!