Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: ??? Error using ==> times !! Matrix dimensions must agree.
Replies: 2   Last Post: Jun 20, 2013 2:22 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Curious

Posts: 1,964
Registered: 12/6/04
Re: ??? Error using ==> times !! Matrix dimensions must agree.
Posted: Jun 20, 2013 2:22 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.