Calculate gain and phase margins and associated crossover frequencies


sysdata (LTI system or (mag, phase, omega) sequence) –

sysStateSpace or TransferFunction

Linear SISO system

mag, phase, omegasequence of array_like

Input magnitude, phase (in deg.), and frequencies (rad/sec) from bode frequency response data


  • gm (float) – Gain margin

  • pm (float) – Phase margin (in degrees)

  • wg (float) – Frequency for gain margin (at phase crossover, phase = -180 degrees)

  • wp (float) – Frequency for phase margin (at gain crossover, gain = 1)

  • Margins are calculated for a SISO open-loop system.

  • If there is more than one gain crossover, the one at the smallest

  • margin (deviation from gain = 1), in absolute sense, is

  • returned. Likewise the smallest phase margin (in absolute sense)

  • is returned.


>>> sys = tf(1, [1, 2, 1, 0])
>>> gm, pm, wg, wp = margin(sys)