Main Content

linmod

Extract continuous-time linear state-space model around operating point

Syntax

argout = linmod('sys')
argout = linmod('sys',x,u)
argout = linmod('sys',x,u,para)
argout = linmod('sys',x,u,'v5')
argout = linmod('sys',x,u,para,'v5')
argout = linmod('sys',x,u,para,xpert,upert,'v5')

Arguments

sys

Name of the Simulink® system from which the linear model is extracted.

x and u

State (x) and the input (u) vectors. If specified, they set the operating point at which the linear model is extracted. When a model has model references using the Model block, you must use the Simulink structure format to specify x. To extract the x structure from the model, use the following command:

x = Simulink.BlockDiagram.getInitialState('sys');

You can then change the operating point values within this structure by editing x.signals.values.

If the state contains different data types (for example, 'double' and 'uint8'), then you cannot use a vector to specify this state. You must use a structure instead. In addition, you can only specify the state as a vector if the state data type is 'double'.

Ts

Sample time of the discrete-time linearized model

'v5'

An optional argument that invokes the perturbation algorithm created prior to MATLAB® 5.3. Invoking this optional argument is equivalent to calling linmodv5.

para

A three-element vector of optional arguments:

  • para(1) — Perturbation value of delta, the value used to perform the perturbation of the states and the inputs of the model. This is valid for linearizations using the 'v5' flag. The default value is 1e-05.

  • para(2) — Linearization time. For blocks that are functions of time, you can set this parameter with a nonnegative value that gives the time (t) at which Simulink evaluates the blocks when linearizing a model. The default value is 0.

  • para(3) — Set para(3)=1 to remove extra states associated with blocks that have no path from input to output. The default value is 0.

xpert and upert

The perturbation values used to perform the perturbation of all the states and inputs of the model. The default values are

xpert = para(1) + 1e-3*para(1)*abs(x)
upert = para(1) + 1e-3*para(1)*abs(u)

When a model has model references using the Model block, you must use the Simulink structure format to specify xpert. To extract the xpert structure, use the following command:

xpert = Simulink.BlockDiagram.getInitialState('sys');

You can then change the perturbation values within this structure by editing xpert.signals.values.

The perturbation input arguments are only available when invoking the perturbation algorithm created prior to MATLAB 5.3, either by calling linmodv5 or specifying the 'v5' input argument to linmod.

argout

linmod, dlinmod, and linmod2 return state-space representations if you specify the output (left-hand) side of the equation as follows:

  • [A,B,C,D] = linmod('sys', x, u) obtains the linearized model of sys around an operating point with the specified state variables x and the input u. If you omit x and u, the default values are zero.

linmod and dlinmod both also return a transfer function and MATLAB data structure representations of the linearized system, depending on how you specify the output (left-hand) side of the equation. Using linmod as an example:

  • [num, den] = linmod('sys', x, u) returns the linearized model in transfer function form.

  • sys_struc = linmod('sys', x, u) returns a structure that contains the linearized model, including state names, input and output names, and information about the operating point.

Description

Note

linmod provides only basic linearization functionality. For full linearization functionality, use Simulink Control Design™ software. For more information, see Choose Linearization Tools (Simulink Control Design).

linmod compute a linear state-space model by linearizing each block in a model individually.

linmod obtains linear models from systems of ordinary differential equations described as Simulink models. Inputs and outputs are denoted in Simulink block diagrams using Inport and Outport blocks.

The default algorithm uses preprogrammed analytic block Jacobians for most blocks which should result in more accurate linearization than numerical perturbation of block inputs and states. A list of blocks that have preprogrammed analytic Jacobians is available in the Simulink Control Design documentation along with a discussion of the block-by-block analytic algorithm for linearization.

The default algorithm also allows for special treatment of problematic blocks such as the Transport Delay and the Quantizer. See the mask dialog of these blocks for more information and options.

Notes

By default, the system time is set to zero. For systems that are dependent on time, you can set the variable para to a two-element vector, where the second element is used to set the value of t at which to obtain the linear model.

The ordering of the states from the nonlinear model to the linear model is maintained. For Simulink systems, a character vector variable that contains the block name associated with each state can be obtained using

[sizes,x0,xstring] = sys

where xstring is a vector of strings whose ith row is the block name associated with the ith state. Inputs and outputs are numbered sequentially on the diagram.

For single-input multi-output systems, you can convert to transfer function form using the routine ss2tf or to zero-pole form using ss2zp. You can also convert the linearized models to LTI objects using ss. This function produces an LTI object in state-space form that can be further converted to transfer function or zero-pole-gain form using tf or zpk.

The default algorithms in linmod handle Transport Delay blocks by replacing the linearization of the blocks with a Pade approximation. For the 'v5' algorithm, linearization of a model that contains Derivative or Transport Delay blocks can be troublesome. For more information, see Linearizing Models.

Linearization is not supported for models that contain one or more referenced models configured to use a local solver. For more information, see Use Local Solvers in Referenced Models.

Examples

Linearization with Referenced Models

You can use linmod to extract a linear model from a Simulink® environment that contains Model blocks. For example, open the referenced model mdlref_dynamics and the top model mdlref_f14.

open_system('mdlref_dynamics');
open_system('mdlref_f14');

In the mdlref_f14 model, the Aircraft Dynamics Model block references the mdlref_dynamics model.

To linearize the mdlref_f14 model, use the linmod command.

[A,B,C,D] = linmod('mdlref_f14');
### Starting serial model reference simulation build.
### Successfully updated the model reference simulation target for: mdlref_dynamics

Build Summary

Simulation targets built:

Model            Action                        Rebuild Reason                              
===========================================================================================
mdlref_dynamics  Code generated and compiled.  mdlref_dynamics_msf.mexa64 does not exist.  

1 of 1 models built (0 models already up to date)
Build duration: 0h 0m 34.563s

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

You can call linmod with a state and input operating point for models that contain Model blocks. When using operating points, the state vector x refers 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, use getInitialState.

x = Simulink.BlockDiagram.getInitialState(topModelName)

Tip

In Normal mode, the linmod command applies the block-by-block linearization algorithm on blocks inside the referenced model. If the Model block is in Accelerator mode, the linmod command 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.

Linearization Using the 'v5' Algorithm

Calling the linmod command 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')
Using linmod with 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 a Derivative block, you can also try to incorporate the derivative term in other blocks. For example, if you have a Derivative block in series with a Transfer Fcn block, it is better implemented (although this is not always possible) with a single Transfer Fcn block of the form

ss+a.

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

Model showing described action.

Version History

Introduced in R2007a

See Also

Functions

Apps

Topics