Adrian Ong - 2014-04-10

I specify the system: H(s) = 10 / (1 + 0.5s + s^2) and use margin(sys) to get the crossover and phase margin. These are reported correctly as: 3.296rad/s, 9.485deg

from matplotlib.pyplot import *
from control.matlab import * 
sys = tf([10],[1,0.5,1])
m, p, omega = bode(sys)
GM, PM, wGM, wPM = margin(sys)
print wPM, PM

>>> 3.29594817549 9.48546573835

Notice, m, p, omega are generated directly from the bode() function. If I send m, p, omega to margin(), I expect to see the same values for crossover and phase margin: 3.296rad/s and 9.485deg. Instead, this is what happens:

GM1, PM1, wGM1, wPM1 = margin(m, p, omega)
print wPM1, PM1

>>> -0.00300640351606 180.014574827

This behavior is observed with python-control v0.6d.

With Matlab R2013a:

sys = tf([10], [1,0.5,1])
[m,p,w] = bode(sys)
[GM, PM, wGM, wPM] = margin(sys)
[GM1, PM1, wGM1, wPM1] = margin(m,p,w)

>> GM = Inf, PM = 9.4852, wGM = Inf, wPM = 3.2960
>> GM1 = 61.7487, PM1 = 9.5085, wGM1 = 24.7272, wPM1 = 3.2968
 

Last edit: Adrian Ong 2014-04-11