The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

Posts: 1
Registered: 6/20/13
??? Error using ==> times !! Matrix dimensions must agree.
Posted: Jun 20, 2013 11:58 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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

This is the code i used.

[song,FS] = wavread('c scale fast.wav');

P=20000/44100*FS; % length of filter
N=length(song); % length of song
t=0:1/FS:(length(song)-1)/FS; % and get sampling frequency


% Gaussian Filter
x = linspace( -1, 1, N); % create a vector of N values between -1 and 1 inclusive

sigma = 0.335; % standard deviation used in Gaussian formula

myFilter = -x .* exp( -(x.^2)/(2*sigma.^2));% compute first derivative, but leave constants out

myFilter = myFilter / sum( abs( myFilter ) ); % normalize

% fft convolution
song = song(:); % create a column vector

myFilter = myFilter(:); % create a coumn vector

song(length(song)+length(myFilter)-1) = 0; %zero pad song

myFilter(length(song)+length(myFilter)-1) = 0; %zero pad myFilter

edges =ifft(fft(song).*fft(myFilter));

tedges=edges(P/2:N+P/2-1); % shift by P/2 so peaks line up w/ edges
tedges=tedges/max(abs(tedges)); % normalize

title('Wave File')
xlabel('Length (in seconds)')
ylim([0 1.1])
xlim([0 N/FS])

title('Song Filtered With Edge Detector')
xlabel('Time (s)')
ylim([-.5 1.1])
xlim([0 N/FS])

title('Edge Detection Filter')

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.

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.