# linmod2

Extract continuous-time linear state-space model around operating point using algorithm that reduces truncation error

## Syntax

``[A,B,C,D] = linmod2(mdl)``
``[A,B,C,D] = linmod2(mdl,x,u)``
``[A,B,C,D] = linmod2(mdl,x,u,opts)``
``[n,d] = linmod2(___)``
``sys = linmod2(___)``

## Description

````[A,B,C,D] = linmod2(mdl)` computes the linear state-space model of the system of ordinary differential equations represented in the model `mdl` by perturbing the model inputs and states using an algorithm that reduces truncation error. Inport and Outport blocks in the model represent the system inputs and outputs. Note`linmod2` provides only basic linearization functionality. For full linearization functionality, use Simulink® Control Design™ software. For more information, see Choose Linearization Tools (Simulink Control Design). ```
````[A,B,C,D] = linmod2(mdl,x,u)` computes the linear state-space model of the system of ordinary differential equations represented in the model `mdl` at the operating point specified by the state values `x` and input values `u`.```
````[A,B,C,D] = linmod2(mdl,x,u,opts)` computes the linear state-space model of the system represented in the model `mdl` at the specified operating point with the options `opts`.```
````[n,d] = linmod2(___)` returns the linearized model in transfer function form.```
````sys = linmod2(___)` returns a structure that contains the linearized model, state names, input and output names, and information about the operating point.```

## Input Arguments

collapse all

Name of model to linearize, specified as a string or a character vector.

Data Types: `char` | `string`

Model states of operating point at which to linearize model, specified as a structure or a vector. The operating point at which to linearize the model is specified as a combination of the model states and the input values.

To extract the state of the model as a structure, use the `Simulink.BlockDiagram.getInitialState` function. You can edit the values of the model state by modifying the `values` field of the `signals` substructure. For example, use these commands to access the values of the state of the model named `mdl`.

```mdlState = Simulink.BlockDiagram.getInitialState("mdl"); stateVals = mdlState.signals.values;```

You must use the structure format to specify the state at which to linearize the model when:

• The model is a model reference hierarchy.

• The model has states that have different data types.

• The model has states that have a data type other than `double`.

Input values of operating point at which to linearize model, specified as a vector. The operating point at which to linearize the model is specified as a combination of the model states and the input values.

Data Types: `double`

Perturbation algorithm options, specified as a vector with the elements and values described in the table.

ElementValueDefault
`opts(1)`Perturbation value of delta used to perturb the model states and inputs.`1e-5`
`opts(2)`Nonnegative time at which to evaluate bocks during linearization.`0`
`opts(3)`

Option to remove extra states from blocks that do not have direct feedthrough.

• `0` — Do not remove extra states from blocks that do not have direct feedthrough.

• `1` — Remove extra states from blocks that do not have direct feedthrough.

`0`

## Output Arguments

collapse all

State-space representation of linearized model, returned as a vector.

Transfer function representation of linearized model, returned as a vector.

Linearized model, returned as a structure that contains state names, input and output names, and information about the operating point.

## Limitations

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

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

## Tips

• By default, the system time is zero. For systems that are dependent on time, you can specify the system time using the second element of the `opts` input argument.

• State order is maintained in linearization such that the order of states in the linearized model matches the order of states in the nonlinear model. You can get information about the states in a model and the blocks associated with the states by using the model name as a programmatic interface to execute the sizes phase. The return argument named `blks` is a vector that contains the name of each block associated with a state. For more information, see Use Model Name as Programmatic Interface.

`[sys,x0,blks,st] = modelName([],[],[],'sizes');`
• You can convert the state-space linearized representation of a linearized single-input, multiple-output system to another form using these functions:

• You can create a state-space model object from a linearized model using the `ss` (Control System Toolbox) function. You can use state-space model objects to represent a linear time invariant (LTI) system for control design. You can also combine multiple LTI state-space models to represent more complex systems.

• After creating a state-space model object, you can convert to transfer function form using the `tf` (Control System Toolbox) function or convert to zero-pole-gain form using the `zpk` (Control System Toolbox) function.

## Version History

Introduced in R2007a