Contents

Ordering States in Linearized Model

Control State Order of Linearized Model using Linear Analysis Tool

This example shows how to control the order of the states in your linearized model. This state order appears in linearization results.

  1. Open and configure the model for linearization.

    sys = 'magball';
    open_system(sys)
    sys_io(1)=linio('magball/Controller',1,'input');
    sys_io(2)=linio('magball/Magnetic Ball Plant',1,'openoutput');
    setlinio(sys,sys_io);
    opspec = operspec(sys);
    op = findop(sys,opspec);

    These commands specify the plant linearization and compute the steady-state operating point.

  2. Open the Linear Analysis Tool for the model.

    In the Simulink® model window, select Analysis > Control Design > Linear Analysis.

  3. Open the Options for exact linearization dialog box.

    In the Exact Linearization tab, click Options.

  4. In the State Ordering tab, select the Enable state ordering check box.

  5. Specify the desired state order using the Move Up and Move Down buttons.

      Tip   If you change the model while its Linear Analysis Tool is open, click Sync with Model to update the list of states.

  6. Linearize the model.

    In the Linear Analysis Tool, click .

    A new linearized model, linsys1, appears in the Linear Analysis Workspace.

  7. View the order of the model states for the linearized model by opening the Linearization result dialog box.

    Click the Linear Analysis tab. Choose Show result details in the Select Report list.

    The linear model states appear in the specified order.

Control State Order of Linearized Model using MATLAB Code

This example shows how to control the order of the states in your linearized model. This state order appears in linearization results.

  1. Load and configure the model for linearization.

    sys = 'magball';
    load_system(sys);
    sys_io(1)=linio('magball/Controller',1,'input');
    sys_io(2)=linio('magball/Magnetic Ball Plant',1,'openoutput');
    opspec = operspec(sys);
    op = findop(sys,opspec);

    These commands specify the plant linearization and compute the steady-state operating point.

  2. Linearize the model, and show the linear model states.

    linsys = linearize(sys,sys_io);
    linsys.StateName

    The linear model states are in default order. The linear model includes only the states in the linearized blocks, and not the states of the full model.

    ans = 
        'height'
        'Current'
        'dhdt'
    
  3. Define a different state order.

    stateorder = {'magball/Magnetic Ball Plant/height';...
                  'magball/Magnetic Ball Plant/dhdt';...
                  'magball/Magnetic Ball Plant/Current'};
  4. Linearize the model again and show the linear model states.

    linsys = linearize(sys,sys_io,'StateOrder',stateorder);
    linsys.StateName

    The linear model states are now in the specified order.

    ans = 
        'height'
        'dhdt'
        'Current'
Was this topic helpful?