Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Curious
Posts:
2,311
Registered:
12/6/04


Re: ??? Error using ==> times !! Matrix dimensions must agree.
Posted:
Jun 20, 2013 2:22 PM


"someone" wrote in message <kpvf75$odc$1@newscl01ah.mathworks.com>... > "Jolini " <jolini25jc@gmail.com> wrote in message <kpv8qk$6k8$1@newscl01ah.mathworks.com>... > > I'm getting the following error message. > > > > ??? Error using ==> times > > Matrix dimensions must agree. > > > > Error in ==> Untitled2 at 28 > > edges =ifft(fft(song).*fft(myFilter)); > >
> > Can someone please help me out with this code so that I get the plots i need and no more error messages. I can't figure out what I'm doing wrong here. > > The error message means that (in your particular case) > fft(song) & fft(myFilter) are of different lengths. > > From the above code, I can't tell what the length of song is (its read in), > but it looks like song & myFilter should be of the same length, although I'm not sure about the statements: > > song(length(song)+length(myFilter)1) = 0; %zero pad song > > myFilter(length(song)+length(myFilter)1) = 0; %zero pad myFilter > > I would check the lengths of song & myFilter after these statements > to make sure they are doing what you think they should. > If you need to zero pad, you could use the form Y = fft(x,n). >
AHAH, now I see it. song(length(song)+length(myFilter)1) = 0; %zero pad song changes the length of song and then myFilter(length(song)+length(myFilter)1) = 0; %zero pad myFilter makes myFilter a different length than song (original opr zero padded).
You need to try something like:
song1 = song; song1(length(song)+length(myFilter)1) = 0; %zero pad song myFilter(length(song)+length(myFilter)1) = 0; %zero pad myFilter song = song1;
as a quick & dirty fix.



