I am getting the following error in my code: "Undefined function or variable 'helperFrequencyAnalysisPlot2'." How do I correct this error?
显示 更早的评论
function [domPks, domF, medF] = domFreqs(d, Fs, n, plots) %UNTITLED Summary of this function goes here % Detailed explanation goes here
% Input % d: data % Fs: sampling freq % n: number of dominant frequenies to return % plots: = 1 to display plots
NFFT = length(d); % Number of FFT points
F = (0 : 1/NFFT : 1/2-1/NFFT)*Fs; % Frequency vector
TEMP = fft(d,NFFT);
TEMP(1) = 0; % remove the DC component for better visualization
[pksTemp,~] = findpeaks(abs(TEMP(1:floor(NFFT/2))));
% Sort frequency peaks
pks = sort(pksTemp,1,'descend');
for i = 1:n
loc(i) = find(abs(TEMP(1:floor(NFFT/2))) == pks(i));
end
if plots == 1
% Plot 1st and 2nd dominant peaks
helperFrequencyAnalysisPlot2(F,abs(TEMP(1:floor(NFFT/2))),...
'Frequency (cycles/s)','Magnitude',[],[],[0 5])
hold on
plot(F(loc),pks(1:n),'ro')
end
domPks = pks(1:n);
domF = F(loc(1:n));
medF = median(pks);
end
回答(1 个)
Walter Roberson
2018-1-2
0 个投票
Chances are that you are trying to use an example code with a version of MATLAB earlier than what the example was designed for.
Which MATLAB version are you using?
类别
在 帮助中心 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!