MATLAB Answers

0

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

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))

??

Log in to comment.

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

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

@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?

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.

Log in to comment.


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today