How can I get the 2 highest peaks ?

1)How can I get the 2 peaks from the picture below? Because these commands gives me the only the highest.
[gpeakG1,fpeakG1] = getPeakGain(G1);
gpeakG1_dB = 20*log10(gpeakG1);

 Risposta accettata

I would use the bode function with three output arguments, then use findpeaks with the ‘mag’ and ‘wout’ arguments:
[mag,phase,wout] = bode(sys);
[pks,locs] = findpeaks(mag, wout);
Add the name-value pair arguments you need to get the result you want. The findpeaks function has considerable flexibility, but how much depends on your version of MATLAB, so be sure to read the relevant documentation for your version.

4 Commenti

Bob
Bob il 25 Mar 2016
Modificato: Bob il 25 Mar 2016
Thanks for your answer,
[mag,phase,wout] = bode(G1);
[pks,locs] = findpeaks(mag, wout);
I got this error:
Error using findpeaks
Expected Y to be a vector.
I have got Matlab 2015a
You have a SISO system, so adding a squeeze call will work:
[pks,locs] = findpeaks(squeeze(mag), wout);
Bob
Bob il 25 Mar 2016
Thank you it works.
My pleasure.

Accedi per commentare.

Più risposte (1)

Image Analyst
Image Analyst il 22 Mar 2016

0 voti

For #2, did you take a look at findpeaks()? (Requires the Signal Processing Toolbox.)

Categorie

Richiesto:

Bob
il 21 Mar 2016

Modificato:

Bob
il 26 Mar 2016

Community Treasure Hunt

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

Start Hunting!

Translated by