Gain margin, phase margin, delay margin, and crossover frequencies
computes the gain margin, phase margin, delay margin, and the corresponding
crossover frequencies for the SISO or MIMO negative feedback loop with open-loop
S = allmargin(
L. The negative feedback loop is computed as
M is the number
of inputs and outputs in
For a MIMO system,
allmargin returns loop-at-a-time stability
margins for the negative-feedback closed loop system. Use
allmargin to find classical margins of any SISO or MIMO
model, including models with delays.
Stability Margins of a Transfer Function
For this example, consider a SISO open-loop transfer function
L given by,
L = tf(25,[1 10 10 10]);
Find the stability margins of
S = allmargin(L)
S = struct with fields: GainMargin: 3.6000 GMFrequency: 3.1623 PhaseMargin: 29.1104 PMFrequency: 1.7844 DelayMargin: 0.2847 DMFrequency: 1.7844 Stable: 1
S is a structure with the classical margins and their respective crossover frequencies of the negative feedback loop of
Stability Margins of a MIMO System
For this example, consider a MIMO state-space model
L with 2 inputs and 2 outputs.
Load the data.
Find the classical margins for the MIMO system.
S = allmargin(L)
S=2×1 struct array with fields: GainMargin GMFrequency PhaseMargin PMFrequency DelayMargin DMFrequency Stable
S is a 2-by-1 structure array of classical margins and their respective crossover frequencies. For instance,
S(1) refers to the stability margins of the first I/O feedback channel with all other loops closed.
Stability Margins of Models in an Array
For this example, load
invertedPendulumArray.mat, which contains a 3-by-3 array of inverted pendulum SISO models. The mass of the pendulum varies as you move from model to model along a single column of
sys, and the length of the pendulum varies as you move along a single row. The mass values used are 100g, 200g and 300g, and the pendulum lengths used are 3m, 2m and 1m respectively.
3x3 array of transfer functions. Each model has 1 outputs and 1 inputs.
Find stability margins for all models in the array.
S = allmargin(sys)
S=3×3 struct array with fields: GainMargin GMFrequency PhaseMargin PMFrequency DelayMargin DMFrequency Stable
allmargin returns a 3-by-3 structure array
S, in which each entry is a structure containing the stability margins of the corresponding entry in
sys. For instance, the stability margins of the model with 100g pendulum weight and 2m length is contained in
Stability Margins from Frequency Response Data
For this example, load the frequency response data of an open loop system, consisting of magnitudes
m and phase values
p measured at the frequencies in
Compute stability margins using the frequency response data.
S = allmargin(m,p,w,ts)
S = struct with fields: GainMargin: 0.6249 GMFrequency: 1.2732 PhaseMargin: [-90.0000 48.9853] PMFrequency: [1.0000 1.5197] DelayMargin: [4.7124 0.5626] DMFrequency: [1.0000 1.5197] Stable: NaN
S is a structure with the classical margins and their respective crossover frequencies. Since
allmargin cannot assess the stability for frequency response data models,
S.Stable = NaN.
L — Open-loop response
dynamic system model | model array
Open-loop response, specified as a dynamic system model.
L can be SISO or MIMO, as long as it has the same
number of inputs and outputs.
allmargin computes the
classical stability margins for the negative-feedback closed-loop system
To compute the stability margins of the positive feedback system
When you have a controller
P and a plant
C, you can compute the stability margins for gain and
phase variations at the plant inputs or outputs. From the following
To compute margins at the plant outputs, set
L = P*C.
To compute margins at the plant inputs, set
L = C*P.
L can be continuous time or discrete time. If
L is a generalized state-space model
allmargin uses the current or nominal value of all
control design blocks in
L is a frequency-response data model (such as
the margins at each frequency represented in the model. The function returns
the margins at the frequency with the smallest stability margin.
L is a model array, then
allmargin computes margins for each model in the
mag — Magnitude of system response
Magnitude of the system response in absolute units, specified as a 3-D
mag is an M-by-M-by-N array, where M is the
number of inputs or outputs, and N is the number of frequency points. For
more information on obtaining
mag, see Obtain Magnitude and Phase Data and Magnitude and Phase of MIMO System.
phase — Phase of system response
w — Frequencies at which the magnitude and phase values of system response are obtained
Frequencies at which the magnitude and phase values of system response are
obtained, specified as a column vector. You can provide the frequency vector
w in any units;
frequencies in the same units.
between frequency points to approximate the true stability margins.
ts — Sample time
Sample time, specified as an integer.
ts to find the stability margins from frequency
For continuous-time models, set
ts = 0.
For discrete-time models,
tsis a positive integer representing the sampling period. To denote a discrete-time model with unspecified sample time, set
ts = -1.
S — Gain, phase, and delay margins
structure | structure array
Gain, phase, and delay margins, returned as a structure array.
S is a structure with the following
GMFrequency: All -180° (modulo 360°) crossover frequencies in
TimeUnitis the time units, specified in the
GainMargin: Corresponding gain margins, defined as
Gis the gain at the -180° crossover frequency. Gain margins are in absolute units.
PMFrequency: All 0-dB crossover frequencies in
TimeUnitis the time units, specified in the
PhaseMargin: Corresponding phase margins in degrees.
DelayMarginis the maximum amount of delay that the system can tolerate before it loses stability.
DMFrequencycontains critical frequencies corresponding to the delay margins. Delay margins are specified in the time units of the system for continuous-time systems and multiples of the sample time for discrete-time systems.
1if the nominal closed-loop system is stable,
0if unstable, and
NaNif stability cannot be assessed. In general,
allmargincannot assess the stability of an
L is an M-by-M MIMO system,
S is an M-by-1 structure array. For instance,
S(j) gives the stability margins for the j-th
feedback channel with all other loops closed (one-loop-at-a-time
allmarginassumes that the system with open-loop response
Lis a negative-feedback system. To compute the classical stability margins of the positive feedback system
To compute classical margins for a system modeled in Simulink®, first linearize the model to obtain the open-loop response at a particular operating point. Then, use
allmarginto compute classical stability margins for the linearized system. For more information, see Stability Margins of a Simulink Model (Robust Control Toolbox).
Introduced before R2006a