Determining the response of a system to small perturbations at an operating point is a critical step in system and controller design. Once you find an operating point, you can linearize the model about that operating point to explore the response and stability of the system. To find an operating point in a Simscape™ model, see Finding an Operating Point.

Near an operating point, you can express the system state ** x**, inputs

If the system dynamics do not explicitly depend on time and
the operating point is a steady state, the system response to state
and input perturbations near the steady state is approximately governed
by a *linear time-invariant* (LTI) state space
model:

d** x**/dt =

** y** =

The matrices *A*, *B*, *C*, *D* have
components and structures that are independent of the simulation time.
A system is stable to changes in state at an operating point if the
eigenvalues of *A* are negative.

If the operating point is not a steady state or the system dynamics
depend explicitly on time, the linearized dynamics near the operating
point are more complicated. The matrices *A*, *B*, *C*, *D* are
not constant and depend on the simulation time *t*_{0} ,
as well as the operating point *x*_{0} and *u*_{0}.

While you can linearize a closed system with no inputs or outputs
and obtain a nonzero *A* matrix, obtaining a nontrivial
linearized input-output model requires at least one input component
in ** u** and one output component in

A pilot is flying, or simulating, an aircraft in level, constant-velocity, and constant-altitude flight relative to the ground. A crucial question for the aircraft pilot and designers is: will the aircraft return to the steady state if perturbed from it by a disturbance, such as a wind gust — in other words, is this steady state stable? If the operating point is unstable, the aircraft trajectory can diverge from the steady state, requiring human or automatic intervention to maintain steady flight.

Although steady-state and other operating points (state *x*_{0} and inputs *u*_{0}) might exist for
your model, that is no guarantee that such operating points are suitable
for linearization. The critical question is: how good is the linearized
approximation compared to the exact system dynamics?

When perturbed slightly, a problematic operating point might exhibit strong asymmetries, with strongly nonlinear behavior when perturbed in one direction and smoother behavior in another.

Small perturbations might result in a discontinuous change in a state value, making the current state unsuitable for linear approximation.

Operating points with a strongly nonlinear or discontinuous character are not suitable for linearization. You should analyze such models in full simulation, away from any discontinuities, and perturb the system by varying its inputs, parameters, and initial conditions. A common example is actuation systems, which should be linearized away from any hard constraints or end stops.

Check for such an unsuitable operating point by linearizing at several nearby operating points. If the results differ greatly, the operating point is strongly nonlinear or discontinuous.

Use the following methods to create numerical linearized state-space models from a model containing Simscape components.

The Simulink^{®}
Control Design™ product is recommended for linearization analysis.

An important difference from basic Simulink models is that the states in a physical network are not independent in general, because some states have dependencies on other states through constraints.

The independent states are a subset of system variables and consist of independent (unconstrained) Simscape dynamic variables and other Simulink states.

The dependent states consist of Simscape algebraic variables and dependent (constrained) Simscape dynamic variables.

For more information on Simscape dynamic and algebraic variables, see How Simscape Simulation Works.

The complete, unreduced LTI *A*, *B*, *C*, *D* matrices
have the following structure.

The

`A`

matrix, of size`n_states`

by`n_states`

, is all zeros except for a submatrix of size`n_ind`

by`n_ind`

, where`n_ind`

is the number of independent states.The

`B`

matrix, of size`n_states`

by`n_inputs`

, is all zeros except for a submatrix of size`n_ind`

by`n_inputs`

.The

`C`

matrix, of size`n_outputs`

by`n_states`

, is all zeros except for a submatrix of size`n_outputs`

by`n_ind`

.The

`D`

matrix, of size`n_outputs`

by`n_inputs`

, can be nonzeros everywhere.

**Obtaining the Independent Subset of States. **A minimal linearized solution uses only an independent subset
of system states. From the matrices *A*, *B*, *C*, *D*,
you can obtain a minimal input-output linearized model with:

The techniques described in this section require the Simulink Control Design product.

You must use the features of this product on the Simulink lines in your model, not directly on Simscape physical network lines or blocks.

This approach requires that you start with an operating point object saved from trimming the model to an operating specification.

To linearize a model with an operating point object, use the `linearize`

function, customizing where
necessary. The resulting state-space object contains the matrices *A*, *B*, *C*, *D*.

You can also use the graphical user interface, through the Simulink Toolstrip: on the **Apps** tab, under
**Control Systems**, click **Model
Linearizer**.

For more information on linearizing Simscape models using Simulink Control Design, see Linearize Simscape Networks (Simulink Control Design).

`linmod`

and `dlinmod`

FunctionsYou have several ways that you can use the Simulink functions `linmod`

and `dlinmod`

,
and the linearization results can differ depending on the method chosen.
To use these functions, you do not have to open the model, just have
the model file on your MATLAB^{®} path.

For more information about Simulink linearization, see Linearizing Models (Simulink).

If your model has continuous states, use `linmod`

.
(Continuous states are the Simscape default.) If your model has
mixed continuous and discrete states, or purely discrete states, use `dlinmod`

.

Linearizing a model with the local solver enabled (in the Solver Configuration block) is not supported.

**Linearizing with Default State and Input. **You can call `linmod`

without specifying state
or input. Enter `linmod('`

at
the command line.* modelname*')

With this form of `linmod`

, Simulink linearization
solves for consistent initial conditions in the same way it does on
the first step of any simulation. Any initial conditions, such as
initial offset from equilibrium for a spring, are set as if the simulation
were starting from the initial time.

`linmod`

allows you to change the time of externally
specified signals (but not the internal system dynamics) from the
default. For this and more details, see the `linmod`

function
reference page.

**Linearizing with the Steady-State Solver at an Initial Steady
State. **You can linearize at an operating point found by the Simscape steady-state
solver:

Open one or more Solver Configuration blocks in your model.

Select the

**Start simulation from steady state**check box for the physical networks that you want to linearize.Close the Solver Configuration dialog boxes and save the modified model.

Enter

`linmod('`

at the command line.')`modelname`

`linmod`

linearizes at the first step of simulation.
In this case, the initial state is also an operating point, a steady
state.

For more about setting up the steady-state solver, see the Solver Configuration block reference page.

**Linearizing with Specified State and Input — Ensuring
Consistency of States. **You can call `linmod`

and specify state and
input. Enter `linmod('`

at
the command line. The extra arguments specify, respectively, the steady
state * modelname*',x0,u0)

`linmod`

,
ensure that it is self-consistent, within solver tolerance.With this form of `linmod`

, Simulink linearization
does not solve for initial conditions. Because not all states in the
model have to be independent, it is possible, though erroneous, to
provide `linmod`

with an inconsistent state to linearize
about.

If you specify a state that is not self-consistent (within solver
tolerance), the Simscape solver issues a warning at the command
line when you attempt linearization. The Simscape solver then
attempts to make the specified `x0`

consistent by
changing some of its components, possibly by large amounts.

You most easily ensure a self-consistent state by taking the
state from some simulated time. For example, by selecting the **States** check
box on the **Data Import/Export** pane of the model
Configuration Parameters dialog box, you can capture a time series
of state values in a simulation run.

You can generate linearized state-space models from your Simscape model by adding a Timed-Based Linearization or Trigger-Based Linearization block to the model and simulating. These blocks combine time-based simulation, up to specified times or internal trigger points, with state-based linearization at those times or trigger points.

For complete details about these blocks, see their respective block reference pages.

If your model contains PS Constant Delay or PS
Variable Delay blocks, or custom blocks utilizing the
`delay`

operator in the Simscape language, it is recommended that you linearize the model by
using the Timed-Based Linearization
or Trigger-Based Linearization
block and simulating the model for a time period longer than the specified
delay time.