Categories &

Functions List

Function Reference: margin

Function File: [gamma, phi, w_gamma, w_phi] = margin (sys)
Function File: [gamma, phi, w_gamma, w_phi] = margin (sys, tol)

Gain and phase margin of a system. If no output arguments are given, both gain and phase margin are plotted on a bode diagram. Otherwise, the margins and their corresponding frequencies are computed and returned. A more robust criterion to assess the stability of a feedback system is the sensitivity Ms computed by function sensitivity.

Inputs

sys

LTI model. Must be a single-input and single-output (SISO) system.

tol

Imaginary parts below tol are assumed to be zero. If not specified, default value sqrt (eps) is taken.

Outputs

gamma

Gain margin (as gain, not dBs).

phi

Phase margin (in degrees).

w_gamma

Frequency for the gain margin (in rad/s).

w_phi

Frequency for the phase margin (in rad/s).

Algorithm
Uses function roots to calculate the frequencies w_gamma, w_phi from special polynomials created from the transfer function of sys as listed below in section «Equations».

Equations

 
 
 CONTINUOUS-TIME SYSTEMS
 Gain Margin
         _               _
 L(jw) = L(jw)      BTW: L(jw) = L(-jw) = conj (L(jw))

 num(jw)   num(-jw)
 ------- = --------
 den(jw)   den(-jw)

 num(jw) den(-jw) = num(-jw) den(jw)

 imag (num(jw) den(-jw)) = 0
 imag (num(-jw) den(jw)) = 0
 
 
 
 
 Phase Margin
           |num(jw)|
 |L(jw)| = |-------| = 1
           |den(jw)|
   _     2      2
 z z = Re z + Im z

 num(jw)   num(-jw)
 ------- * -------- = 1
 den(jw)   den(-jw)

 num(jw) num(-jw) - den(jw) den(-jw) = 0

 real (num(jw) num(-jw) - den(jw) den(-jw)) = 0
 
 
 
 
 DISCRETE-TIME SYSTEMS
 Gain Margin
                              jwT         log z
 L(z) = L(1/z)      BTW: z = e    --> w = -----
                                           j T
 num(z)   num(1/z)
 ------ = --------
 den(z)   den(1/z)

 num(z) den(1/z) - num(1/z) den(z) = 0
 
 
 
 
 Phase Margin
          |num(z)|
 |L(z)| = |------| = 1
          |den(z)|
 
 
 
 
 L(z) L(1/z) = 1

 num(z)   num(1/z)
 ------ * -------- = 1
 den(z)   den(1/z)

 num(z) num(1/z) - den(z) den(1/z) = 0
 
 
 
 
 PS: How to get L(1/z)
           4       3       2
 p(z) = a z  +  b z  +  c z  +  d z  +  e

             -4      -3      -2      -1
 p(1/z) = a z  +  b z  +  c z  +  d z  +  e

           -4                    2       3       4
        = z   ( a  +  b z  +  c z  +  d z  +  e z  )

               4       3       2                     4
        = ( e z  +  d z  +  c z  +  b z  +  a ) / ( z  )
 
 

See also: sensitivity, roots

Source Code: margin