所以我写了下面的代码,我得到一个错误,上面写着:
Error using ==> times
Matrix dimensions must agree.
Error in ==> Untitled2 at 28
edges =ifft(fft(song).*fft(myFilter));
这是我使用的代码:
[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
myFilter = myFilter / sum( abs( myFilter ) ); % normalize
% fft convolution
song = song(:);
myFilter = myFilter(:);
song(length(song)+length(myFilter)-1) = 0;
myFilter(length(song)+length(myFilter)-1) = 0;
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
有人可以告诉我这里有什么问题吗?