load 'xdata.txt'
load 'ydata.txt'

[pn,minp,maxp,tn,mint,maxt] = premnmx(xdata,ydata);

net=newff([-1 1],[10 1],{'logsig', 'purelin'}, 'traincgf');

net = init(net);

ptr = pn(1:2:length(pn))
ttr= tn(1:2:length(tn))

val.P=pn(2:2:length(pn))
val.T=tn(2:2:length(tn))

a = sim(net,pn);

net.trainParam.epochs=2000;
net.trainParam.lr = 50;
net.trainParam.goal = 0.01;
[net tr]=train(net,pn,tn,[],[],val);
a = sim(net,pn);


figure(2)
plot(pn,tn,'g*')
hold on
xp=-1:.01:1;
yp=sim(net,xp);
plot(xp,yp)
