Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matlab NARX with multiple inputs

Status
Not open for further replies.

ShwaZmoto

Mechanical
Jul 28, 2008
10
thread575-155285

I realize this is a bit late, but hopefully this may save someone else a headache in the future. It's currently 2010 and Matlab's documentation on this subject still isn't any better than it was in 2006. Instead of doing something like this:

a={[0.1] [0.2] [0.3] [0.4] [0.5] [0.6] [0.7] [0.8] [0.9] [1.0]};
b={[-0.1] [0.2] [-0.3] [0.4] [-0.5] [0.6] [-0.7] [0.8] [-0.9] [1.0]};
c={[-0.2] [0.4] [-0.6] [0.8] [-0.2] [0.4] [-0.6] [0.8] [-0.2] [0.4]};
d1=[1 2];
d2=[1 2];
narx_net = newnarxsp({[0.1 1.0],[-0.9 1.0],[-0.6 0.8]},d1,d2,[5 1],{'tansig','purelin'});
p=[a;b;c] ;
t=c;
narx_net.trainFcn = 'trainbr';
narx_net.trainParam.show = 10;
narx_net.trainParam.epochs = 600;
narx_net = train(narx_net,p,t);

Do something like this:

a=cell2mat(a);
b=cell2mat(b);
c=cell2mat(c);
d1=[1 2];
d2=[1 2];
narx_net = newnarxsp({[0.1 1.0;-0.9 1.0],[-0.6 0.8]},d1,d2,[5 1],{'tansig','purelin'});
p=[a;b;c];
P=mat2cell(p,[size(p,1)-1 1],ones(size(p,2),1));
T=mat2cell(c,1,ones(size(c,2),1));
narx_net.trainFcn = 'trainbr';
narx_net.trainParam.show = 10;
narx_net.trainParam.epochs = 600;
narx_net=train(narx_net,P,T);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor