fft error: Not enough input arguments.

조회 수: 4 (최근 30일)
Fernando
Fernando 2012년 1월 19일
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)
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 1월 19일
What does
which -all fft
report?
Fernando
Fernando 2012년 1월 20일
This function read a heart-beat sound with Fs=16000, format .wav, and determines the heart rate.
I am developing work to the chair of theory of signs at the university, and i find this code in a website, and dicided use it for improve my work, but it didn´t work.
I need to confess that i am new in matlab.
The report in matlab is:
>> homoFreq
Error using homoFreq (line 12)
Not enough input arguments.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
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
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.
Fernando
Fernando 2012년 1월 20일
I think that understand what you suggest.
Thanks a lot.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Dr. Seis
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.

카테고리

Help CenterFile Exchange에서 AI for Audio에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by