%% Simulate State-Space Models Containing Unknown Parameters
% To generate variates from a state-space model, specify values for all unknown parameters.
% Explicitly create this state-space model.
% \begin{array}{*{20}{c}}
% {{x_t} = \phi {x_{t - 1}} + {\sigma _1}{u_t}}\\
% {{y_t} = {x_t} + {\sigma _2}{\varepsilon _t}}
% \end{array}
% where u_t and \varepsilon_t are independent Gaussian random variables with mean 0 and variance 1. Suppose that the initial state mean and variance are 1, and that the state is a stationary process.

A = NaN;
B = NaN;
C = 1;
D = NaN;
mean0 = 1;
cov0 = 1;
stateType = 0;

Mdl = ssm(A,B,C,D,'Mean0',mean0,'Cov0',cov0,'StateType',stateType);

%
% Simulate 100 responses from Mdl. Specify that the autoregressive coefficient is 0.75, the state disturbance standard deviation is 0.5, and the observation innovation standard deviation is 0.25.

params = [0.75 0.5 0.25];
y = simulate(Mdl,100,'Params',params);

figure;
plot(y);
title 'Simulated Responses';
xlabel 'Period';

% The software searches for NaN values column-wise following the order A, B, C, D, Mean0, and Cov0. The order of the elements in params should correspond to this search.
% Copyright 2012 The MathWorks, Inc.