Repository navigation
Documentation for margin command is incorrect #195
Description
Activity
Changing the gain of your system will affect both the gain margin (by exactly the inverse of the change in gain) and the phase margin (because you shift the frequency at which the gain crosses unity and it is the phase at unity gain(s) that determines the phase margin).
You misunderstand the issue. I'm not talking about the actual margins. I'm talking frequencies.
The order of the frequencies returned by the function
margindisagree with the order specified on the wiki.Edit: I've attached a code snippet demonstrating the issue. The print function is in accordance to what the wiki specifies the function returns:

Notice how Wcp changes... (it shouldn't)
Thanks for the extra info. You are right that I misunderstood the issue you were pointing out, and you are correct that the documentation for the
control.margin()function is incorrect.Just for posterity, here is what is going on in a bit more detail:
-
In python-control, according to the documentation for
control.margins(),Wcgis the gain crossover frequency (corresponding to phase margin) andWcpis the phase crossover frequency (corresponding to gain margin). What the documentation says is the order of the return values is:- gm = Gain margin
- pm = Phase margin (in degrees)
- Wcg = Gain crossover frequency (corresponding to phase margin)
- Wcp = Phase crossover frequency (corresponding to gain margin) (in rad/sec)
-
What is actually returned is a subset of the return values in the order of the
control.stability_margins()function, which is- gm = Gain margin
- pm = Phase margin
- sm = Stability margin, the minimum distance from the Nyquist plot to -1
- wg = Gain margin crossover frequency (where phase crosses -180 degrees)
- wp = Phase margin crossover frequency (where gain crosses 0 dB)
- ws = Stability margin frequency (where Nyquist plot is closest to -1)
-
In MATLAB, the relevant function call is
[Gm,Pm,Wgm,Wpm] = margin(sys)whereWgmis 'the frequency where the gain margin is measured' (from MATLAB documentation) andWpmis 'the frequency where the phase margin is measured'. This is the same ascontrol.stability_margins().
So the problem is that the documentation for
control.marginis incorrect.Since I'm doing a bit of work on the code today, I'll try to post a PR to fix this soon. @repagh and @blinkminster: I think one or both of you worked on this in the past, so if you happen to be online and I am missing something in terms of what is going on, let me know.
-
- changed the title
[-]output of margin in wrong order[/-][+]Documentation for margin command is incorrect[/+]on Feb 24, 2018 - added a commit that references this issue
on Jul 2, 2018 Fixed in PR #198.
Reacted by Padraic McAtee
The wiki specifies the output of margin to be gm,pm,Wcg,Wcp. This doesn't appear to be accurate. Varying proportional gains of my system should change Wcg and not Wcp.