%% Create State-Space Model with Random State Coefficient
% This example shows how to create a time-varying, state-space model
% containing a random, state coefficient.
%%
% Write a function that specifies how the parameters in |params| map to the
% state-space model matrices, the initial state values, and the type of
% state. Symbolically, the model is
%
% $$\begin{array}{*{20}{c}}
% {\left[ {\begin{array}{*{20}{c}}
% {{x_{1,t}}}\\
% {{x_{2,t}}}
% \end{array}} \right] = \left[ {\begin{array}{*{20}{c}}
% 1&0\\
% 0&\phi 
% \end{array}} \right]\left[ {\begin{array}{*{20}{c}}
% {{x_{1,t - 1}}}\\
% {{x_{2,t - 1}}}
% \end{array}} \right] + \left[ {\begin{array}{*{20}{c}}
% 1&0\\
% 0&\sigma 
% \end{array}} \right]\left[ {\begin{array}{*{20}{c}}
% {{u_{1,t}}}\\
% {{u_{2,t}}}
% \end{array}} \right]}\\
% {{y_t} = \left[ {\begin{array}{*{20}{c}}
% 1&1
% \end{array}} \right]\left[ {\begin{array}{*{20}{c}}
% {{x_{1,t}}}\\
% {{x_{2,t}}}
% \end{array}} \right] + {\varepsilon _t}}
% \end{array}.$$
%
% $\phi$ is a random coefficient.
%
% <include>randomCoeffParamMap.m</include>
% 
%%
% Create the state-space model by passing |randomCoeffParamMap| as a
% function handle to |ssm|.

% Copyright 2015 The MathWorks, Inc.

rng('default'); % For reproducibility 
Mdl = ssm(@randomCoeffParamMap);
%%
% |ssm| implicitly creates the |ssm| model |Mdl|.
%%
% Display |Mdl| using |disp|. Specify initial parameters values.
disp(Mdl,[3; 5])
%%
% |disp| sets the parameters to their initial values, or functions of
% their initial values. In this case, the first parameter is the initial
% values times a random number.