% Demo file for using the armax.m function in 
% the System Identification Toolbox (IDENT)
% Version 6.1 (R14SP1) 05-Sep-2004.
% Model used and experiment as in Exercise 15.

% The model matrices, noise free deterministic part of Exercise 15 model
A=[-1.5 1;-0.7 0]; B=[2;-1.3]; D=[1,0]; E=-1;

% Simulate the model and generate data files Y og U.
N=1000;
k=1:N;
U=sin(k/5)'+sin(k/10)';
Y=dlsim(A,B,D,E,U);

% Using armax.m
dat=iddata(Y,U);              % Packing the data matrices Y og U
M=armax(dat,[2,3,2,0]);       % Identify an armax model in, M, polynomial format.
[a,b,d,e]=ssdata(M)           % Transform the polynom model to a state space model
