How can we determine how many peaks are at each plot?
1 回表示 (過去 30 日間)
古いコメントを表示
How can we determine how many peaks are at each plot?
0 件のコメント
回答 (1 件)
Sulaymon Eshkabilov
2023 年 5 月 12 日
Use findpeaks() fcn: see DOC
e.g.:
t = linspace(0, 2, 1000); % Time
fs = 1/t(2); % Sampling freq [Hz]
f1 = 5; % Freq 1.
f2 = 25; % Freq 2.
f3 = 50; % Freq 3.
f4 = 100; % Freq 4.
% Signal generated with some noise effect
S = 5*sin(2*pi*t*f1)+2*cos(2*pi*t*f2)+1.5*sin(2*pi*t*f3)+.5*cos(2*pi*t*f4)+.1*randn(size(t));
% FFT caclculations:
L = length(S);
n = 2^nextpow2(L);
Y= fft(S, n);
f = fs*(0:(n/2))/n;
P2 = abs(Y/n);
P1 = P2(1:n/2+1);
P1(2:end-1) = 2*P1(2:end-1);
plot(f,P1)
title("FFT")
xlabel("f (Hz)")
ylabel("|P(f)|^2")
Peak_Freq_Values_ALL = findpeaks(P1);
figure(2)
findpeaks(P1,f, 'MinPeakProminence',.25,'Annotate','extents');
title("FFT with Peak Freq values")
xlabel("f (Hz)")
ylabel("|P(f)|^2")
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Fourier Analysis and Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!