Gain margin, phase margin, and crossover frequencies

`margin(sys)`

`[Gm,Pm,Wcg,Wcp] = margin(sys)`

`[Gm,Pm,Wcg,Wcp] = margin(mag,phase,w)`

`[Gm,Pm] = margin(sys,J1,...,JN)`

`margin(`

plots the Bode response
of `sys`

)`sys`

on the screen and indicates the gain and phase
margins on the plot. Gain margins are expressed in dB on the plot.

Solid vertical lines mark the gain margin and phase margin. The dashed
vertical lines indicate the locations of `Wcp`

, the frequency
where the phase margin is measured, and `Wcg`

, the frequency
where the gain margin is measured. The plot title includes the magnitude and
location of the gain and phase margin.

`Gm`

and `Pm`

of a system indicate the
relative stability of the closed-loop system formed by applying unit negative
feedback to `sys`

, as shown in the following figure.

`Gm`

is the amount of gain variance required to make the loop
gain unity at the frequency `Wcg`

where the phase angle is
–180° (modulo 360°). In other words, the gain margin is 1/*g*
if *g* is the gain at the –180° phase frequency. Similarly, the
phase margin is the difference between the phase of the response and –180° when
the loop gain is 1.0.

The frequency `Wcp`

at which the magnitude is 1.0 is called
the *unity-gain frequency* or *gain crossover
frequency*. Usually, gain margins of three or more combined with
phase margins between 30° and 60° result in reasonable tradeoffs between
bandwidth and
stability.

`[`

returns the gain margin `Gm`

,`Pm`

,`Wcg`

,`Wcp`

] = margin(`sys`

)`Gm`

in absolute units, the phase
margin `Pm`

, and the corresponding frequencies
`Wcg`

and `Wcp`

, of
`sys`

. `Wcg`

is the frequency where
the gain margin is measured, which is a –180° phase crossing frequency.
`Wcp`

is the frequency where the phase margin is
measured, which is a 0-dB gain crossing frequency. These frequencies are
expressed in radians/`TimeUnit`

, where
`TimeUnit`

is the unit specified in the
`TimeUnit`

property of `sys`

. When
`sys`

has several crossovers, `margin`

returns the smallest gain and phase margins and corresponding
frequencies.

When you use

`margin(mag,phase,w)`

,`margin`

relies on interpolation to approximate the margins, which generally produce less accurate results. For example, if there is no 0-dB crossing within the`w`

range,`margin`

returns a phase margin of`Inf`

. Therefore, if you have an analytical model`sys`

, using`[Gm,Pm,Wcg,Wcp] = margin(sys)`

is a more robust way to obtain the margins.