Inner Matrix Dimensions Must Agree

조회 수: 1 (최근 30일)
shawin
shawin 2018년 9월 1일
편집: KALYAN ACHARJYA 2018년 9월 4일
I have a matrix of 119 x 1 and Z is 119 x 119
should multiply it by a diagonal matrix of 2 x 2:
W = [0.12 0 ;
0 0.28];
d=sqrt(W*X'*Z*X*W);
I am receiving an error which is:
Inner Matrix Must agree!!
Please, any suggestion?

답변 (2개)

Image Analyst
Image Analyst 2018년 9월 1일
That can never work. If all you have is dimensions of 119 and 1, then there is no way you can do anything to get 2 rows or 2 columns, no matter what you do or how you manipulate (transpose) them. The result will always have dimensions of 119 and/or 1 - never 2. Therefore, you will never be able to right multiply, or left multiply, by a 2-by-2 matrix W.
  댓글 수: 2
shawin
shawin 2018년 9월 1일
편집: shawin 2018년 9월 1일
If we move row by row, what I mean multiply each row by a 2x2 matrix ?
Image Analyst
Image Analyst 2018년 9월 1일
편집: Image Analyst 2018년 9월 1일
A row is a 1-by-N array, and that cannot be multiplied by a 2-by-2 matrix. If you have two matrices, an a-by-b called m1, and a c-by-d matrix called m2, then to do m1*m2 you must have b equal c, and if you do m2*m1 you must have d equal a. That's just basic matrix algebra rules.

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


KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 9월 1일
편집: KALYAN ACHARJYA 2018년 9월 4일
  • Matrix multiplication rows of the first matrix should be equal columns of the second matrix
  • you have considering one matrix is 2x2 order, how can you do the multiplication with 1x119 or 119x119
x=rand(119,1); )%Order 119x1
z=rand(119,119); %Order 119x119
w=[0.12 0; 0 0.28]; %Order 2x2
%x' order 1x119
d=sqrt(w.*x'*z.*x.*w); %This does not work, check the order of all Matrixes
Learn Matrix multiplication here
  댓글 수: 4
Stephen23
Stephen23 2018년 9월 4일
편집: Stephen23 2018년 9월 4일
"Matrix multiplication rows of the first matrix should be equal columns of the second matrix or vice versa"
The number of columns of the first matrix must be equal to the number of rows of the second matrix. There is certainly no "vice versa" involved.
KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 9월 4일
편집: KALYAN ACHARJYA 2018년 9월 4일
Yes @Stephen Cobeldick, Thanks for pointing the error

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by