Impulse response plot of dynamic system; impulse response data
impulse(sys)
impulse(sys,Tfinal)
impulse(sys,t)
impulse(sys1,sys2,...,sysN)
impulse(sys1,sys2,...,sysN,Tfinal)
impulse(sys1,sys2,...,sysN,t)
[y,t] = impulse(sys)
[y,t] = impulse(sys,Tfinal)
y = impulse(sys,t)
[y,t,x] = impulse(sys)
[y,t,x,ysd] = impulse(sys)
impulse
calculates the unit impulse response of adynamic system model.For continuous-time dynamic systems, the impulse response is the response to a Dirac inputδ(t). For discrete-time systems, the impulse response is the response to a unit area pulse of lengthTs
and height1/Ts
, whereTs
is the sample time of the system. (This pulse approachesδ(t) asTs
approaches zero.) For state-space models,impulse
assumes initial state values are zero.
impulse(sys)
plots the impulse response of the dynamic system modelsys
. This model can be continuous or discrete, and SISO orMIMO. The impulse response of multi-input systems is the collection of impulse responses for each input channel. The duration of simulation is determined automatically to display the transient behavior of the response.
impulse(sys,Tfinal)
simulates the impulse response fromt = 0
to the final timet = Tfinal
. ExpressTfinal
in the system time units, specified in theTimeUnit
property ofsys
. For discrete-time systems with unspecified sample time (Ts = -1
),impulse
interpretsTfinal
as the number of sampling periods to simulate.
impulse(sys,t)
uses the user-supplied time vectort
for simulation. Expresst
in the system time units, specified in theTimeUnit
property ofsys
. For discrete-time models,t
should be of the formTi:Ts:Tf
, whereTs
is the sample time. For continuous-time models,t
should be of the formTi:dt:Tf
, wheredt
becomes the sample time of a discrete approximation to the continuous system (seeAlgorithms). Theimpulse
command always applies the impulse att=0
, regardless ofTi
.
To plot the impulse responses of several modelssys1
,...,sysN
on a single figure, use:
impulse(sys1,sys2,...,sysN)
impulse(sys1,sys2,...,sysN,Tfinal)
impulse(sys1,sys2,...,sysN,t)
As withbode
orplot
, you can specify a particular color, linestyle, and/or marker for each system, for example,
impulse(sys1,'y:',sys2,'g--')
See "Plotting and Comparing Multiple Systems" and thebode
entry in this section for more details.
When invoked with output arguments:
[y,t] = impulse(sys)
[y,t] = impulse(sys,Tfinal)
y = impulse(sys,t)
impulse
returns the output responsey
and the time vectort
used for simulation (if not supplied as an argument to impulse). No plot is drawn on the screen. For single-input systems,y
has as many rows as time samples (length oft
), and as many columns as outputs. In the multi-input case, the impulse responses of each input channel are stacked up along the third dimension ofy
. The dimensions ofy
are then
For state-space models only:
[y,t,x] = impulse(sys)
(length oft) × (number of outputs) × (number of inputs)
andy(:,:,j)
gives the response to an impulse disturbance entering thej
th input channel. Similarly, the dimensions ofx
are
(length oft) × (number of states) × (number of inputs)
[y,t,x,ysd] = impulse(sys)
returns the standard deviationYSD
of the responseY
of an identified systemSYS
.YSD
is empty ifSYS
does not contain parameter covariance information.
Plot the impulse response of the second-order state-space model
a = [-0.5572 -0.7814;0.7814 0]; b = [1 -1;0 2]; c = [1.9691 6.4493]; sys = ss(a,b,c,0); impulse(sys)
The left plot shows the impulse response of the first input channel, and the right plot shows the impulse response of the second input channel.
You can store the impulse response data in MATLAB®arrays by
[y,t] = impulse(sys);
Because this system has two inputs,y
is a 3-D array with dimensions
size(y)
ans =1×3139 1 2
(the first dimension is the length oft
). The impulse response of the first input channel is then accessed by
ch1 = y(:,:,1); size(ch1)
ans =1×2139 1
Fetch the impulse response and the corresponding 1 std uncertainty of an identified linear system .
load(fullfile(matlabroot, 'toolbox', 'ident', 'iddemos', 'data', 'dcmotordata')); z = iddata(y, u, 0.1, 'Name', 'DC-motor'); set(z, 'InputName', 'Voltage', 'InputUnit', 'V'); set(z, 'OutputName', {'Angular position', 'Angular velocity'}); set(z, 'OutputUnit', {'rad', 'rad/s'}); set(z, 'Tstart', 0, 'TimeUnit', 's'); model = tfest(z,2); [y,t,~,ysd] = impulse(model,2); % Plot 3 std uncertainty subplot(211) plot(t,y(:,1), t,y(:,1)+3*ysd(:,1),'k:', t,y(:,1)-3*ysd(:,1),'k:') subplot(212) plot(t,y(:,2), t,y(:,2)+3*ysd(:,2),'k:', t,y(:,2)-3*ysd(:,2),'k:')
The impulse response of a continuous system with nonzeroDmatrix is infinite att=0.impulse
ignores this discontinuity and returns the lower continuity valueCbatt=0.
You can change the properties of your plot, for example the units. For information on the ways to change properties of your plots, seeWays to Customize Plots.
Continuous-time models are first converted to state space. The impulse response of a single-input state-space model
is equivalent to the following unforced response with initial stateb.
To simulate this response, the system is discretized using zero-order hold on the inputs. The sample time is chosen automatically based on the system dynamics, except when a time vectort = 0:dt:Tf
is supplied (dt
is then used as sample time).