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


Jolini
Posts:
1
Registered:
6/20/13


??? Error using ==> times !! Matrix dimensions must agree.
Posted:
Jun 20, 2013 11:58 AM


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/21); % 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.



