Calculate gain and phase margins and associated crossover frequencies


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

sysStateSpace or TransferFunction

Linear SISO system representing the loop transfer function

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)

  • wpc (float or array_like) – Phase crossover frequency (where phase crosses -180 degrees)

  • wgc (float or array_like) – Gain crossover frequency (where gain crosses 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)