Skip to Main Content Skip to Search
Product Documentation

Analyzing Stability Margins

Using the loopmargin Command

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.

How Stability Margin Analysis Using Loopmargin Differs Between Simulink and LTI Models

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.

How to Analyze Stability Margin of Simulink Models

The loopmargin command computes the following types of stability margins:

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:

  1. Specify the block where you want to define a margin analysis point.

  2. 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.

  3. 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.

Example — Computing Stability Margins of a Simulink Model

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.

  1. Open the Simulink model:

    airframemargin

    The Simulink model, as shown in the following figure opens.

  2. Define a margin analysis point at the output of the Airframe Model block by typing:

    block1 = 'airframemargin/Airframe Model';

  3. Specify the output az of the Airframe Model block as a margin analysis point by typing:

    port1 = 1;

  4. Compute stability margins by typing:

    [cm,dm,mm] = loopmargin('airframemargin',block1,port1);

  5. 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
    
  6. 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.

  


Free Control Systems Interactive Kit

Learn more about resources for designing, testing, and implementing control systems.

Get free kit

Trials Available

Try the latest control systems products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS