Main Content

Linearizing Models

About Linearizing Models

The Simulink®product provides thelinmod,linmod2, anddlinmodfunctions to extract linear models in the form of the state-space matricesA,B,C, andD. State-space matrices describe the linear input-output relationship as

x ˙ = A x + B u y = C x + D u ,

wherex,u, andyare state, input, and output vectors, respectively.For example, the following model is calledlmod.

To extract the linear model of this system, enter this command.

[A,B,C,D] = linmod('lmod') A = -2 -1 -1 1 0 0 0 1 -1 B = 1 0 0 C = 0 1 0 0 0 -1 D = 0 1

Inputs and outputs must be defined usingInportandOutportblocks from the Ports & Subsystems library. Source and sink blocks do not act as inputs and outputs. Inport blocks can be used in conjunction with source blocks, using aSumblock. Once the data is in the state-space form or converted to an LTI object, you can apply functions inthe Control System Toolbox™ product for further analysis:

  • Conversion to an LTI object

    sys = ss(A,B,C,D);
  • Bode phase and magnitude frequency plot

    bode(A,B,C,D) or bode(sys)
  • Linearized time response

    step(A,B,C,D) or step(sys) impulse(A,B,C,D) or impulse(sys) lsim(A,B,C,D,u,t) or lsim(sys,u,t)

You can use other functions in the Control System Toolbox and the Robust Control Toolbox™ products for linear control system design.

当模型是非线性的,一个操作点n be chosen at which to extract the linearized model. Extra arguments tolinmodspecify the operating point.

[A,B,C,D] = linmod('sys', x, u)

For discrete systems or mixed continuous and discrete systems, use the functiondlinmod线性化。这个函数的年代ame calling syntax aslinmodexcept that the second right-hand argument must contain a sample time at which to perform the linearization.

Linearization with Referenced Models

You can uselinmodto extract a linear model from a Simulink environment that contains Model blocks.

Note

In Normal mode, thelinmodcommand applies the block-by-block linearization algorithm on blocks inside the referenced model. If the Model block is in Accelerator mode, thelinmodcommand uses numerical perturbation to linearize the referenced model. Due to limitations on linearizing multirate Model blocks in Accelerator mode, you should use Normal mode simulation for all models referenced by Model blocks when linearizing with referenced models. For an explanation of the block-by-block linearization algorithm, see theSimulink Control Design™documentation.

For example,openthe referenced modelmdlref_dynamicsand top modelmdlref_f14.

open_system([docroot'/toolbox/simulink/ug/examples/analysis/mdlref_dynamics']); open_system([docroot'/toolbox/simulink/ug/examples/analysis/mdlref_f14'])
The Aircraft Dynamics Model block refers to the modelmdlref_dynamics.

To linearize themdlref_f14model, call thelinmodcommand on the topmdlref_f14model as follows.

[A,B,C,D] = linmod('mdlref_f14')

The resulting state-space model corresponds to the completef14model, including the referenced model.

You can calllinmodwith a state and input operating point for models that contain Model blocks. When using operating points, the state vectorxrefers to the total state vector for the top model and any referenced models. You must enter the state vector using the structure format. To get the complete state vector, call

x = Simulink.BlockDiagram.getInitialState(topModelName)

Linearization Using the 'v5' Algorithm

Calling thelinmodcommand with the'v5'argument invokes the perturbation algorithm created prior to MATLAB®software version 5.3. This algorithm also allows you to specify the perturbation values used to perform the perturbation of all the states and inputs of the model.

[A,B,C,D]=linmod('sys',x,u,para,xpert,upert,'v5')
Usinglinmodwith the'v5'option to linearize a model that contains Derivative or Transport Delay blocks can be troublesome. Before linearizing, replace these blocks with specially designed blocks that avoid the problems. These blocks are in the Simulink Extras library in the Linearization sublibrary.

You access the Extras library by opening the Blocksets & Toolboxes icon:

  • For the Derivative block, use the Switched derivative for linearization.

When using aDerivativeblock, you can also try to incorporate the derivative term in other blocks. For example, if you have aDerivativeblock in series with aTransfer Fcnblock, it is better implemented (although this is not always possible) with a singleTransfer Fcnblock of the form

s s + a .

In this example, the blocks on the left of this figure can be replaced by the block on the right.

See Also

|