% Listing 9.1 of the book 
% "Principles of System Identification: Theory and Practice"

% Arun K. Tangirala
% April 02, 2015
% Freely distributed under no warranty

%% Generate the white-noise input
ek = randn(2000,1);

%% Set up the MA(2) model coefficients
cvec = [1 1.3 0.4];
% Filter the white-noise with the MA model
vk = filter(cvec,1,ek);
% Plot the ACF
vk_acf = acf(vk,20,1);
% Create the iddata object
vkdata = iddata(vk,[],1);
% Estimate the MA(2) parameters
mod_ma = armax(vkdata,'na',0,'nc',2);