%% Explicitly Create State-Space Model with Observation Error
% Create a state-space model containing two independent, autoregressive states, and the observations are the sum of the two states, plus Gaussian error. Symbolically, the equation is
% \left[
% {\begin{array}{*{20}{c}}{{x_{t,1}}}\\{{x_{t,2}}}\end{array}} \right] =
% \left[ {\begin{array}{*{20}{c}}{{\phi _1}}&0\\0&{{\phi _2}}\end{array}}
% \right]\left[ {\begin{array}{*{20}{c}}{{x_{t - 1,1}}}\\{{x_{t -
% 1,2}}}\end{array}} \right] + \left[
% {\begin{array}{*{20}{c}}{\sigma_1} & 0\\0 & \sigma_2\end{array}} \right]\left[
% {\begin{array}{*{20}{c}}{{u_{t,1}}}\\{{u_{t,2}}}\end{array}}
% \right]
% {y_t} = \left[ {\begin{array}{*{20}{c}}1&1\end{array}}
% \right]\left[
% {\begin{array}{*{20}{c}}{{x_{t,1}}}\\{{x_{t,2}}}\end{array}}
% \right]+\sigma_3\varepsilon_t.
% Define the state-transition matrix.

A = [NaN 0; 0 NaN];

%
% Define the state-disturbance-loading matrix.

B = [NaN 0; 0 NaN];

%
% Define the measurement-sensitivity matrix.

C = [1 1];

%
% Define the observation-innovation matrix.

D = NaN;

%
% Create the state-space model using ssm.

 Mdl = ssm(A,B,C,D)

% Mdl is an ssm model containing unknown parameters. A detailed summary of Mdl prints to the Command Window.
% It is good practice to verify that the state and observations equations are correct. If the equations are not correct, then it might help to expand the state-space equation manually.
% Pass the data and Mdl to estimate to estimate the parameters.
% Copyright 2015 The MathWorks, Inc.