%% Simulate an Impulse Response Function
% Specify a mean zero ARIMA(2,0,1) model.

Mdl = arima('Constant',0,'AR',{0.5,-0.8},'MA',-0.5,...
    'Variance',0.1);

%
% Simulate the first 20 responses of the impulse response function. Generate a disturbance series with a one-time, unit impulse, and then filter it. Set all presample observations equal to zero. Normalize the impulse response function to ensure that the first element is 1.

Z = [1;zeros(19,1)];
Y = filter(Mdl,Z,'Y0',zeros(Mdl.P,1));
Y = Y/Y(1);

%
% Plot the impulse response function.

figure;
stem((0:numel(Y)-1)',Y,'filled');
title 'Impulse Response';

% The impulse response assesses the dynamic behavior of a system to a one-time, unit impulse. You can also use the impulse method to plot the impulse response function for an ARIMA process.
% Copyright 2015 The MathWorks, Inc.