| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Control System Toolbox |
| Contents | Index |
| Learn more about Control System Toolbox |
margin
[Gm,Pm,Wg,Wp] = margin(sys)
[Gm,Pm,Wg,Wp] = margin(mag,phase,w)
margin calculates the minimum gain margin, Gm, phase margin, Pm, and associated crossover frequencies of SISO open-loop models, Wg and Wp. The gain and phase margins indicate the relative stability of the control system when the loop is closed. When invoked without left-hand arguments, margin produces a Bode plot and displays the margins on this plot.
The gain margin is the amount of gain increase required to make
the loop gain unity at the frequency where the phase angle is -180°.
In other words, the gain margin is
if
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 at which the magnitude is
1.0 is called the unity-gain frequency or crossover
frequency. It is generally found that gain margins of three
or more combined with phase margins between 30 and 60 degrees result
in reasonable trade-offs between bandwidth and stability.
[Gm,Pm,Wg,Wp] = margin(sys) computes the gain margin Gm, the phase margin Pm, and the corresponding crossover frequencies Wg and Wp, given the SISO open-loop model sys. Wg is the frequency where the gain margin is measured, which is a -180 deg phase crossing frequency. Wp is the frequency where the phase margin is measured, which is a 0dB gain crossing frequency. This function handles both continuous- and discrete-time cases. When faced with several crossover frequencies, margin returns the smallest gain and phase margins.
The phase margin Pm is in degrees. The gain margin Gm is an absolute magnitude. You can compute the gain margin in dB by
Gm_dB = 20*log10(Gm)
[Gm,Pm,Wg,Wp] = margin(mag,phase,w) derives the gain and phase margins from the Bode frequency response data (magnitude, phase, and frequency vector). Interpolation is performed between the frequency points to estimate the margin values. This approach is generally less accurate.
When invoked without left-hand argument,
margin(sys)
plots the open-loop Bode response with the gain and phase margins marked by vertical lines. By default, gain margins are expressed in dB when plotting.
You can compute the gain and phase margins of the open-loop discrete-time transfer function. Type
hd = tf([0.04798 0.0464],[1 -1.81 0.9048],0.1)
This command produces the following result.
Transfer function: 0.04798 z + 0.0464 --------------------- z^2 - 1.81 z + 0.9048 Sampling time: 0.1
Type
[Gm,Pm,Wg,Wp] = margin(hd);
This command produces the following result.
ans =
2.0517 13.5711 5.4374 4.3544
You can also display these margins graphically.
margin(hd)

The phase margin is computed using
theory,
and the gain margin by solving
for the frequency
.
![]() | mag2db | minreal | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |