function [net2]=arma1
%function arma1 which passes net2 to the work space
% file: arma1.m 
%
% m-function to form an arma filter as a neural network
%  02/23/07 RWN
% degnum = degree of numerator in 1/z
% degden = degree of denominator in 1/z
%
degnum=input('enter the degree of the numerator: ');
if degnum == [ ]
	degnum=3
end
%
degden=input('enter the degree of the denominator: ');
if degden == [ ]
	degden = 3
end 
P = input('enter the exemplar input vector P: ');
% for versions 6.5, 7 can not use: if p==[]
if size(P) == 0
	P=[-0.5:0.1:0.5];
end
T = input('enter the exemplar output vector T: ');
if size(T) == 0
	T=[-0.2:0.1:0.8];
end
%
%define a new neural network
net1=network;
%
% set up properties of the network. It should have one input layer with degnum % % delays from the input P and degden delays which are fed by the output via
% the layer connecting to itself
net1.numInputs=1;
net1.numLayers=1;
net1.inputConnect(1,1)=1;
net1.layerConnect(1,1)=1;
net1.outputConnect=1;
net1.targetConnect=1;
net1.inputs{1}.range=[-1, 1];
net1.layers{1}.transferFcn='purelin';
net1.layers{1}.initFcn='initnw';
net1.initFcn='initlay';
net1.performFcn='mse';
%
net1.trainFcn='trainlm';
% net1.trainFcn='trainrp'
net1.trainParam.goal=1e-2;
net1.trainParam.epochs=500
net1.inputWeights{1,1}.delays=[0:1:degnum];
net1.layerWeights{1,1}.delays=[1:1:degden];
%
% initialize the network
net1=init(net1)
% next is to train and test default samples
% 
 P1=con2seq(P); T1=con2seq(T);
 net2=train(net1,P1,T1);
% may need to reset some training parameters, as mu
 Y=sim(net2,P1);
 Y1=seq2con(Y);
 plot(P,T,'-',P,Y1{1},'+')
 xlabel('P'); ylabel('T as -, Y as +');
 % end
