lsim
Plot simulated time response of dynamic system to arbitrary inputs; simulated response data
Syntax
Description
Response Plots
lsim(
plots the simulated time response of thedynamic system modelsys
,u
,t
)sys
to the input history (t
,u
). The vectort
specifies the time samples for the simulation. For single-input systems, the input signalu
is a vector of the same length ast
。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 tosys
。
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 thesys
1,sys
2,...,sys
N,u
,t
,___)x0
andmethod
input arguments when computing the responses of multiple models.
Response Data
returns the system responsey
= lsim(sys
,u
,t
)y
, sampled at the same timest
as the input. For single-output systems,y
is a vector of the same length ast
。对于多输出系统,y
is an array having as many rows as there are time samples (length(t)
) and as many columns as there are outputs insys
。This syntax does not generate a plot.
Linear Simulation Tool
lsim(
opens the Linear Simulation Tool. For more information about using this tool for linear analysis, seeWorking with the Linear Simulation Tool(Control System Toolbox)。sys
)
Examples
Input Arguments
Output Arguments
Tips
When you need additional plot customization options, use
lsimplot
instead.
Algorithms
For a discrete-time transfer function,
lsim
filters the input based on the recursion associated with this transfer function:
For discrete-timezpk
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,
For continuous-time systems,lsim
first discretizes the system usingc2d
, and then propagates the resulting discrete-time state-space equations. Unless you specify otherwise with themethod
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 spacingdT
between the time samples you supply int
。