Filter löschen
Filter löschen

how to fix error inner matrix dimensions must agree problem

9 Ansichten (letzte 30 Tage)
segun
segun am 24 Jan. 2015
Bearbeitet: Andrew Newell am 25 Mär. 2015
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;

Akzeptierte Antwort

Image Analyst
Image Analyst am 24 Jan. 2015
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 Kommentare
segun
segun am 24 Jan. 2015
??? Error using ==> times Matrix dimensions must agree.
Error in ==> CASCADED at 68 W1=P1.*Q1.*V.*P2.*Q2;
Image Analyst
Image Analyst am 24 Jan. 2015
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by