MATLAB: Is the gain margin returned by the MARGIN function in the Control Systems Toolbox different than the gain margin shown in the associated bode plot

bodecompareControl System Toolboxdbdifferentgainmarginplot

When I compare the gain margin returned by the MARGIN command to that shown in the Bode plot produced by the same command, I notice that they are not the same.
The gain margin Gm returned by the MARGIN command:
[Gm,Pm,Wg,Wp] = margin(sys)
is unitless. The gain margin shown in the bode plot produced by the command:
margin(sys)
has units of dB.

Best Answer

This enhancement has been incorporated in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
To convert the gain margin Gm to have units in dB, use the following code:
Gm_dB = 20*log10(Gm)