how to fix error inner matrix dimensions must agree problem
조회 수: 11 (최근 30일)
이전 댓글 표시
I got this error when i did the multiplication of matrices that consist of both complex numbers ,integers and zeros shown below:
??? Error using ==> mtimes
Inner matrix dimensions must agree.
W1 = P1.*Q1.*V.*P2.*Q2;
댓글 수: 0
채택된 답변
Image Analyst
2015년 1월 24일
You're doing element-by-element multiplication, NOT matrix multiplication, so that means the rows of all 5 matrixes must be the same and the columns of all 5 matrixes must be the same. You do not have that.
But your partial error message indicates that it thinks it's doing a matrix multiplication, not an element-by-element operation. So the columns of the left matrix must match the number of rows in the left matrix. You don't have that either.
Please post the ENTIRE ERROR MESSAGE . This means ALL the red text , not just a paraphrased subset of the message like you did, which probably had an error when you re-wrote it. I know you didn't give the entire error message because the entire error message will always give line numbers and what you showed us did not have that.
댓글 수: 4
Image Analyst
2015년 1월 24일
Aaaaaaand, you did it again. OK, let's just forget about that and assume you wrote it (the partial error message) in here correctly. Let's just look at one of the products - the product of V and P2. So V.*P2 is a 2*2 multiplied by a 2*101. Can you give me an actual numerical example of how that would work? So you multiply V(1,1) by P(1,1), and you multiply V(1,2) by P(1,2), and you multiply V(2,1) by P(2,1), and you multiply V(2,2) by P(2,2). OK, fine so far. But what elements of V are you going to multiply the (1,3) element of P2 by? There is no (1,3) element of V! Don't you see? You can't do that.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!