Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Why does it give the error "Matrix dimensions must agree"??

Asked by Rohit Deo on 19 Sep 2013

[y,Fs]=wavread('abc.wav'); y=y/(1.01*abs(max(y))); yy=buffer(y,909); N=909; w=window(@hamming,N); fnl=yy.*w;

2 Comments

dpb on 19 Sep 2013

Cuz they don't??? :)

[y,Fs]=wavread('abc.wav'); 
y=y/(1.01*abs(max(y))); 
yy=buffer(y,909); 
N=909; 
w=window(@hamming,N); 
fnl=yy.*w;

Check what is

size(max(y))

??

Rohit Deo on 20 Sep 2013

thanks :)

Rohit Deo

Products

No products are associated with this question.

1 Answer

Answer by Jan Simon on 19 Sep 2013
Accepted answer

Perhaps the wav file is in stereo. Then abs(max(y)) is a vector and dividing y by this vector leads to this problem. Or perhaps yy and w do not have equal sizes, such that yy.*w must fail.

It would be useful if you post the complete error message, such that we do not have to guess, where the error occurs.

3 Comments

Rohit Deo on 19 Sep 2013

Dear Sir, the error is posted as it is. and the error is occuring at the line of: fnl=yy.*w

Jan Simon on 19 Sep 2013

@Rohit: No, "Matrix dimensions must agree" is not the complete message. When you want to discuss an error in the forum, post everything, which belongs to the error message, even if you do not know, if it matters.

You can check the sizes of yy and w by inserting this code:

size(yy)
size(w)

What do you see and what should yy .* w achieve then?

Rohit Deo on 20 Sep 2013

Got it Sir! The error is: ??? Error using ==> times Matrix dimensions must agree.

Error in ==> abc at 12 fnl=yy.*w;

Thank you Sir. size() has helped a lot to me. And now, what I've done is,

xy=yy(:,n); fnl=xy.*w;

Now it is working. As I was for n= 0 to (the number of frames i.e-82) Thank you Sir.

Jan Simon

Contact us