| Contents | Index |
Robust Control Toolbox provides the loopmargin command to analyze the stability margins of LTI models created in MATLAB and Simulink models. To use loopmargin with Simulink models, you must have the Simulink Control Design software. This section describes the difference between the MATLAB and Simulink approaches of using loopmargin and the workflow for computing the stability margin of Simulinkmodels. For more information on how to analyze the stability margins of LTI models, see Nominal Stability Margins section in the Robust Control Toolbox Getting Started Guide.
When analyzing stability margins of LTI models using the syntax [cm,dm,mm] = loopmargin(P,C), the software assumes the input and output of the linear plant P as the margin analysis points, as shown in the following figure.

Analyzing stability margin of Simulink models differs from analyzing stability margin of LTI models because you can enter specific margin analysis points in the Simulink model. For more information on how to assign margin analysis points in Simulink models, see the "Usage with Simulink" section of the loopmargin reference page.
The loopmargin command computes the following types of stability margins:
Loop-at-a-time classical gain and phase margins
Loop-at-a-time disk margins
Multi-loop disk margin
To learn more about these stability margins, see the Algorithms section of the loopmargin reference page.
The loopmargin command computes the stability margin based on linearization of Simulink models. To compute stability margins of a Simulink model:
Specify the block where you want to define a margin analysis point.
Specify the output port of the block where you want the margin analysis point.
The software performs the analysis by opening the loop at all specified margin analysis point.
Use the loopmargin command to compute the stability margins at the margin analysis point.
Optionally, you can compare the classical gain and phase margins obtained using loopmargin with the stability margins computed for the linearized model. The results using the two approaches should match for simple SISO models. For MIMO models, the loopmargin command provides richer robustness information. For an example, see Example — Computing Stability Margins of a Simulink Model.
Additionally, you can compute stability margins by specifying multiple margin analysis points and multiple operating points. For an example, see the Loop Margins for an Airframe Autopilot demo.
This example illustrates how to compute the stability margins of the airframemargin model and compare the results with stability margins computed using the linearized model.
airframemargin
The Simulink model, as shown in the following figure opens.

Define a margin analysis point at the output of the Airframe Model block by typing:
block1 = 'airframemargin/Airframe Model';
Specify the output az of the Airframe Model block as a margin analysis point by typing:
port1 = 1;
Compute stability margins by typing:
[cm,dm,mm] = loopmargin('airframemargin',block1,port1);
View the classical gain and phase margins:
cm
MATLAB return the following results:
cm =
GainMargin: [4.5652 2.5055e+003]
GMFrequency: [7.1979 314.1593]
PhaseMargin: 65.1907
PMFrequency: 2.1463
DelayMargin: 53.0113
DMFrequency: 2.1463
Stable: 1
Compare the classical gain and phase margins cm with stability margins of the linearized model computed using allmargin:
% Define linearization I/O points.
io = linio('airframemargin/Airframe Model',1,'outin','on');
% Linearize the model.
lin_sys = linearize('airframemargin',io);
% Compute gain and phase margins.
cm_lin = allmargin(-lin_sys);
MATLAB returns the following results:
cm_lin =
GainMargin: [4.5652 2.5055e+003]
GMFrequency: [7.1979 314.1593]
PhaseMargin: 65.1907
PMFrequency: 2.1463
DelayMargin: 53.0113
DMFrequency: 2.1463
Stable: 1
The gain and phase margins, cm and cm_lin, computed using the two approaches match.
![]() | Computing Uncertain State-Space Models from Simulink Models |

Learn more about resources for designing, testing, and implementing control systems.
Get free kit| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |