简体   繁体   中英

How to programatically find the magnitude and frequency for a given phase in a bode plot?

If I have a Plant let's say

Gp(s) = 1/(s+1)

I can find the Phase Margin

Using MATLAB commands

Gp = tf([1],[1 1]);
[G P] = margin(Gp);

My question is what if I want to know the phase over frequency in a specific Gain Over Frequency. How do I find it without looking to bode plot?

Usually I find it by the command bode(Gp) and move the mouse over the specific gain that I want to know the phase margin on it.

For my previous example The Gain Over Frequency is 0.363 at -20 Phase Over Frequency.

How do I write it as a command not looking in the bode diagram?

Thanks in advance

It seems you misunderstood what Gain Over Frequency and phase margin actually means, and it is not the place to explain it. What I assume you actually want, is a way to evaluate a bode-plot without clicking at it. Eg you want to know magnitude and frequency at the point of -20 phase .

Let's have a look at these three cases:


Case 1: you know the frequency and you're searching for magnitude and phase

The easiest case:

w = 0.363;                 % specify given frequency
[mag,phase] = bode(Gp,w)   % output of according magnitude and phase

returns:

mag =

    0.9400


phase =

  -19.9509

Case 2: you want to know magnitude and frequency for a certain phase

p = -20;
[mag,phase,wout] = bode(Gp);

mag_p = interp1( squeeze(phase), squeeze(mag), p)
w_p   = interp1( squeeze(phase), wout, p)

returns:

mag_p =

    0.9394

w_p =

    0.3642

Case 3: you want to know phase and frequency for a certain magnitude

m = 0.9394;
[mag,phase,wout] = bode(Gp);

phase_m = interp1( squeeze(mag), squeeze(phase), m)
w_m     = interp1( squeeze(mag), wout, m)

returns:

phase_m =

  -19.9998


w_m =

    0.3642

The squeeze command is necessary, because bode output a 1x1x... matrix for phase and magnitude, however. You also may use different interpolation methods of interp1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM