Main Content

impulse

Impulse response plot of dynamic system; impulse response data

Syntax

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)

Description

impulsecalculates 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 lengthTsand height1/Ts, whereTsis the sample time of the system. (This pulse approachesδ(t) asTsapproaches zero.) For state-space models,impulseassumes 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 = 0to the final timet = Tfinal. ExpressTfinalin the system time units, specified in theTimeUnitproperty ofsys. For discrete-time systems with unspecified sample time (Ts = -1),impulseinterpretsTfinalas the number of sampling periods to simulate.

impulse(sys,t)uses the user-supplied time vectortfor simulation. Expresstin the system time units, specified in theTimeUnitproperty ofsys. For discrete-time models,tshould be of the formTi:Ts:Tf, whereTsis the sample time. For continuous-time models,tshould be of the formTi:dt:Tf, wheredtbecomes the sample time of a discrete approximation to the continuous system (seeAlgorithms). Theimpulsecommand always applies the impulse att=0, regardless ofTi.

To plot the impulse responses of several modelssys1,...,sysNon a single figure, use:

impulse(sys1,sys2,...,sysN)

impulse(sys1,sys2,...,sysN,Tfinal)

impulse(sys1,sys2,...,sysN,t)

As withbodeorplot, 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 thebodeentry in this section for more details.

When invoked with output arguments:

[y,t] = impulse(sys)

[y,t] = impulse(sys,Tfinal)

y = impulse(sys,t)

impulsereturns the output responseyand the time vectortused for simulation (if not supplied as an argument to impulse). No plot is drawn on the screen. For single-input systems,yhas 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 ofyare 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 thejth input channel. Similarly, the dimensions ofxare

(length oft) × (number of states) × (number of inputs)

[y,t,x,ysd] = impulse(sys)returns the standard deviationYSDof the responseYof an identified systemSYS.YSDis empty ifSYSdoes not contain parameter covariance information.

Examples

Impulse Response Plot of Second-Order State-Space Model

Plot the impulse response of the second-order state-space model

[ x ˙ 1 x ˙ 2 ] = [ 0.5572 0.7814 0.7814 0 ] [ x 1 x 2 ] + [ 1 1 0 2 ] [ u 1 u 2 ] y = [ 1.9691 6.4493 ] [ x 1 x 2 ]

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)

Figure contains 2 axes objects. Axes object 1 with title From: In(1) contains an object of type line. This object represents sys. Axes object 2 with title From: In(2) contains an object of type line. This object represents 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,yis 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

Impulse Data from Identified System

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:')

Limitations

The impulse response of a continuous system with nonzeroDmatrix is infinite att=0.impulseignores this discontinuity and returns the lower continuity valueCbatt=0.

Tips

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.

Algorithms

Continuous-time models are first converted to state space. The impulse response of a single-input state-space model

x ˙ = A x + b u y = C x

is equivalent to the following unforced response with initial stateb.

x ˙ = A x , x ( 0 ) = b y = C x

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:Tfis supplied (dtis then used as sample time).

Introduced before R2006a