How can we determine how many peaks are at each plot?
Mostra commenti meno recenti
How can we determine how many peaks are at each plot?

Risposte (1)
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")
Categorie
Scopri di più su Descriptive Statistics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

