Matrix does not want to multiply and gives an error when I multiply a 3x3 matrix with a 3x1 matrix
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Steven Lord
2024 年 5 月 16 日
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
回答 (4 件)
Voss
2024 年 5 月 8 日
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 件のコメント
sai charan sampara
2024 年 5 月 8 日
編集済み: sai charan sampara
2024 年 5 月 8 日
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 件のコメント
Ahmed Abed
2024 年 5 月 16 日
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 件のコメント
Stephen23
2024 年 5 月 16 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!