%% Simulate and Filter Disturbance Path Through GARCH Model
% Specify a GARCH(1,1) model with Gaussian innovations.

Mdl = garch('Constant',0.005,'GARCH',0.8,'ARCH',0.1);

%
% Simulate the model using Monte Carlo simulation. Then, standardize the simulated innovations and filter them.

rng(1); % For reproducibility
[v,e] = simulate(Mdl,100,'E0',0,'V0',0.05);
Z = e./sqrt(v);
[V,E] = filter(Mdl,Z,'Z0',0,'V0',0.05);

%
% Confirm that the outputs of simulate and filter are identical.

isequal(v,V)

% The logical value 1 confirms that the two outputs are identical.
% Copyright 2015 The MathWorks, Inc.