how can i multiply two matrices?

5 ビュー (過去 30 日間)
Naseeba PP
Naseeba PP 2017 年 2 月 23 日
回答済み: Alicia Palmerin-Jimenez 2022 年 3 月 5 日
I have a matrix 'a' with size 3x3 and 'b' with size 3x1.i want to multiply the inverse of 'a' with matrix 'b'.I tried the below code but got an error "Matrix dimensions must agree". please help to solve this
a=[1 0 -3; 2 -2 1; 0 -1 3];
inv_a=inv(a);
b=[0;2;121];
c=inv_a.*b;
  2 件のコメント
Beder
Beder 2017 年 2 月 23 日
This code does not produce any error on my system. Maybe you have a variable called "inv" which overlays the function "inv"?
Walter Roberson
Walter Roberson 2017 年 2 月 23 日
Beder,
I suspect you are using R2016b, which introduced automatic vector expansion as if bsxfun() had been used.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2017 年 2 月 23 日
c=inv_a * b;
not .*
inv_a is a 3 x 3 matrix, and you want algebraic matrix multiplication by the 3 x 1 matrix b in order to get the 3 x 1 solution.
  1 件のコメント
Naseeba PP
Naseeba PP 2017 年 2 月 23 日
Thank you

サインインしてコメントする。

その他の回答 (1 件)

Alicia Palmerin-Jimenez
Alicia Palmerin-Jimenez 2022 年 3 月 5 日
no

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by