2
votes

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

1
this is basically a math question. You can find a similar question and answer hereRobert Seifert
@user2485710: no. Rather Electrical Engineering SE - but actually the OP should do some research about control systems and what is to do mathematically, which is quite easy. Then it's a programming problem again, solvable with fzero as described in the answer linked above. For a complete answer the question is way too broad.Robert Seifert
@thewaywewalk I think that the main focus is on the physics, an engineer will use his own know-how in physics to explain this, it's basically the same thing.user2485710
@thewaywewalk Thanks for the editing and answering.Rayanh

1 Answers

7
votes

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. E.g. 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.