fft error: Not enough input arguments.
4 次查看(过去 30 天)
显示 更早的评论
Someone can help me in this code for know de heart frequency.
function homoFreq(y,Fs,nfft)
% x is input signal
% nfft is number of fft points
Fs = 16000;%sampling rate
% subplot(2,1,1),plot(x);
% title('Waveform'), xlabel('Time (ms)'), ylabel('Amplitude');
[y,Fs]=wavread('*.wav'); %* is for file name
t=((1:length(y))-1)/Fs;
figure();
plot(t,y); %only for check
ht=fft((y.*hamming(length(y))),nfft); %nfft point -----> fft error in this line
freqAxis=Fs/2*length(ht)/Fs;
f=(0:freqAxis)*Fs/length(ht);
% subplot(2,1,2);
spec = 20*log10(abs(ht(1:length(f))));
plot(f,spec);ylim([-50 35]);
title('Spectrum'), xlabel('Frequency'),ylabel('Log Magnitude');
[pks,locs] = findpeaks(spec);
for m = 5:5,
differ(m-4) = locs(m)-locs(m-1);
%finding the difference between 5th...
%and 4th peak of the spectrum
end
pitchFreq = mean(differ)*Fs/nfft;
fprintf('Pitch Frequency in Frequency Domain = %gHz\n', pitchFreq)
采纳的回答
Walter Roberson
2012-1-20
You need to invoke
homoFreq([], [], NFFT)
where NFFT is the number of points you want to use for the fft.
3 个评论
Dr. Seis
2012-1-20
He is simply suggesting you replace "NFFT" with the number of points you want to use. For example:
homeFreq([],[],1024)
The number you replace NFFT with depends on if you want to truncate "y", keep "y" the same length, or pad "y" with zeros until its length is equal to NFFT.
更多回答(1 个)
Dr. Seis
2012-1-20
When you run the function as "homFreq" (with no input arguments) from the command line (or from the editor) you aren't defining "nfft" before it is being called at line 12.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 AI for Audio 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!