%% Simulate a Step Response
% Simulate the step response function of a regression model with ARMA(2,1) errors.
% The step response assesses the dynamic behavior of a system to a persistent shock. Typically, the magnitude of the shock is 1. Alternatively, it might be more meaningful to examine a step response of a persistent innovation shock with a magnitude of one standard deviation. This example plots the step response of a persistent innovations shock in a model without an intercept and predictor matrix for regression. However, note that filter is flexible in that it accepts a persistent innovations or predictor shock that you construct using any magnitude, then filters it through the model.
% Specify the following regression model with ARMA(2,1) errors:
% \begin{array}{c}
% {y_t} = {u_t}\\
% {u_t} = 0.5{u_{t - 1}} - 0.8{u_{t - 2}} + {\varepsilon _t} - 0.5{\varepsilon _{t - 1}},
% \end{array}
% where \varepsilon_t is Gaussian with variance 0.1.

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

%
% Simulate the first 30 responses to a sequence of unit errors by generating an error series of one standard deviation, and then filtering it.

z = sqrt(Mdl.Variance)*ones(30,1);...
    % Persistent shock of one std
y = filter(Mdl,z);            
y = y/y(1);  % Normalize relative to y(1)

%
% Plot the step response function.

figure
stem((0:numel(y)-1)',y,'filled')
title('Step Response for Persistent Shock of One STD')

% The step response settles around 0.4.
% Copyright 2012 The MathWorks, Inc.