Main Content

Plot simulated time response of dynamic system to arbitrary inputs; simulated response data

`lsim(`

plots the simulated time response of the dynamic system
model
`sys`

,`u`

,`t`

)`sys`

to the input history
(`t`

,`u`

). The vector `t`

specifies the time samples for the simulation. For single-input systems, the input signal
`u`

is a vector of the same length as `t`

. For
multi-input systems, `u`

is an array with as many rows as there are
time samples (`length(t)`

) and as many columns as there are inputs to
`sys`

.

`lsim(`

simulates the responses of several dynamic system models to the same input history and
plots these responses on a single figure. All systems must have the same number of inputs
and outputs. You can also use the `sys`

1,`sys`

2,...,`sys`

N,`u`

,`t`

,___)`x0`

and `method`

input arguments when computing the responses of multiple models.

returns the system response `y`

= lsim(`sys`

,`u`

,`t`

)`y`

, sampled at the same times
`t`

as the input. For single-output systems, `y`

is a vector of the same length as `t`

. For multi-output systems,
`y`

is an array having as many rows as there are time samples
(`length(t)`

) and as many columns as there are outputs in
`sys`

. This syntax does not generate a plot.

`lsim(`

opens the Linear Simulation Tool.
For more information about using this tool for linear analysis, see Working with the Linear Simulation
Tool (Control System Toolbox).`sys`

)

When you need additional plot customization options, use

`lsimplot`

instead.

For a discrete-time transfer function,

$$sys\left({z}^{-1}\right)=\frac{{a}_{0}+{a}_{1}{z}^{-1}+\dots +{a}_{n}{z}^{-n}}{1+{b}_{1}{z}^{-1}+\dots +{b}_{n}{z}^{-n}},$$

`lsim`

filters the input based on the recursion associated with this
transfer function:

$$y\left[k\right]={a}_{0}u\left[k\right]+\dots +{a}_{n}u\left[k-n\right]-{b}_{1}y\left[k-1\right]-\dots -{b}_{n}\left[k-n\right].$$

For discrete-time `zpk`

models, `lsim`

filters the input
through a series of first-order or second-order sections. This approach avoids forming the
numerator and denominator polynomials, which can cause numerical instability for higher-order
models.

For discrete-time state-space models, `lsim`

propagates the
discrete-time state-space equations,

$$\begin{array}{c}x\left[n+1\right]=Ax\left[n\right]+Bu\left[n\right],\\ y\left[n\right]=Cx\left[n\right]+Du\left[n\right].\end{array}$$

For continuous-time systems, `lsim`

first discretizes the system using
`c2d`

, and then propagates the resulting discrete-time state-space
equations. Unless you specify otherwise with the `method`

input argument,
`lsim`

uses the first-order-hold discretization method when the input
signal is smooth, and zero-order hold when the input signal is discontinuous, such as for
pulses or square waves. The sample time for discretization is the spacing
`dT`

between the time samples you supply in `t`

.

`impulse`

|`lsiminfo`

|`lsimplot`

|`sim`

|`step`

|`gensig`

(Control System Toolbox) |`initial`

(Control System Toolbox)

- Linear System Analyzer (Control System Toolbox)