필터 지우기
필터 지우기

Matrix multiplication have error

조회 수: 1 (최근 30일)
Maximum
Maximum 2015년 5월 7일
댓글: Purushottama Rao 2015년 5월 7일
Hi guys.
I want to multiply this matrix in matlab. But, I have error in matlab which is "inner matrix dimension must agree". My matrix A is A = [1; 2; 3; 4]. While matrix B is B = [1 2 3 4 5 6 7; 8 9 10 11 12 13 14; 15 16 17 18 19 20 21]. How can I multiply this matrix in matlab. Kindly help me please.
  댓글 수: 1
Star Strider
Star Strider 2015년 5월 7일
You can’t multiply them. They have to have at least one dimension in common, and A is (4x1) and B is (3x7).

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2015년 5월 7일
It is not possible to do matrix multiplication between a matrix of size 3 x 7, and a vector of length 1 x 4. In order to do matrix multiplication C * D, the second dimension of C (number of rows) must be the same as the first dimension of D (number of columns). The "1" of the vector does not match either 3 or 7, and the "4" of the vector does not match either 3 or 7, so there is no combination of switching positions or transposing that can be used to do matrix multiplication between the two.
If your vector A were length 3 instead of 4, then A * B would not work because (3 x 1) * (3 x 7) does not have the second dimension of the first, 1, match the 3. Likewise B * A would not work because (3 x 7) * (3 x 1) would not have the 7 match the 3. But, A' * B where the ' indicates transposition, would be (1 x 3) * (3 x 7) and so could execute, producing 1 x 7;and B' * A = (7 x 3) * (3 x 1) could execute, producing 7 x 1.

Purushottama Rao
Purushottama Rao 2015년 5월 7일
Pls refer the basic matrix multiplication rules. you can not multiply a 4*1 matirx with 3*7 matrix.
  댓글 수: 1
Purushottama Rao
Purushottama Rao 2015년 5월 7일
If u want to multiply matrices, inner dimensions should match. EX: you can multiply a matrix of size 3*4 with 4*8 since the inner dimenstion (4) matches. THIS OPERATION RESULTS IN A 3*8 MATRIX

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by