%%%% COMPARISON OF DIFFERENT ANN STRUCTURES %%%%%%
clear all
close all

% DATA
test=(0:0.002:1.1)';
xt=test;
esum=0.*(rand(size(xt))-0.5);
tt=30*(100*((xt-0.6).^2).*(xt-0.1).*(xt-0.8)-5*exp(-5*xt)+0.9*sin(20*xt+pi/4))+esum;

%Neural networks
rand('state',1)
net = newff([0 length(xt)],[1 1],{'tansig' 'purelin'},'trainlm');
net.trainParam.epochs = 1000;
net = train(net,xt',tt');
yNN=sim(net,test');
       
y=30*(100*((test-0.6).^2).*(test-0.1).*(test-0.8)-5*exp(-5*test)+0.9*sin(20*test+pi/4));
figure(1)
plot(test,y,'k:',test,yNN','k')
legend('original','NN model')
title('Results of modelling')
axis([0 1.1 -150 220])
grid