%% Convert an AR(3) Model to an MA(5) Model
% Find the first five lag coefficients of the MA approximation of this univariate and stationary AR(3) model
% y_t =  -0.2y_{t-1} + 0.5y_{t-3} + \varepsilon_t.
% The AR model is in difference-equation notation because the left side contains only y_t and its coefficient of 1. Create a cell vector containing the AR lag term coefficient in order starting from t - 1. Because the second lag term of the MA model is missing, specify a 0 for its coefficient.

ar0 = {-0.2 0 0.5};

%
% Convert the AR model to an MA model with at most five lag coefficients of the truncated approximation of the infinite-lag polynomial. Because there is no MA contribution, specify an empty cell ({}) for the MA coefficients.

numLags = 5;
ma0 = {}; 
ma = arma2ma(ar0,ma0,numLags)

% ma is a cell vector of scalars because at least one of ar0 and ma0 is a cell vector.
% The approximate MA(5) model is
% y_t = \varepsilon_t - 0.2\varepsilon_{t-1} + 0.04\varepsilon_{t-2} +
% 0.492\varepsilon_{t-3} - 0.1984\varepsilon_{t-4} + 0.0597 \varepsilon_{t-5}
% Copyright 2015 The MathWorks, Inc.