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 ]
Jolini

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

song=song/max(abs(song));

% 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

figure(1);
subplot(3,1,1)
plot(t,song)
title('Wave File')
ylabel('Amplitude')
xlabel('Length (in seconds)')
ylim([0 1.1])
xlim([0 N/FS])



subplot(3,1,2)
plot([1/FS:1/FS:N/FS],tedges)
title('Song Filtered With Edge Detector')
xlabel('Time (s)')
ylabel('Amplitude')
ylim([-.5 1.1])
xlim([0 N/FS])


subplot(3,1,3)
plot(myFilter)
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]

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