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개)

Alicia Palmerin-Jimenez
Alicia Palmerin-Jimenez 2022년 3월 5일
no

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by