clear;
clf;
close all;

 a= load('trgSine.dat');

IP = a(:,1);
OP = a(:,2);

IP=IP';
OP=OP';

HiddenLayer1Nodes=15;
OutputLayerNodes =1;

net_c = newff(minmax(IP),[HiddenLayer1Nodes OutputLayerNodes],{'logsig','logsig'},'trainlm');

%Setting related parameters
net_c.performFcn = 'sse';        % Sum-Squared Error performance function
net_c.trainParam.goal = 0.001;     % Sum-squared error goal.
net_c.trainParam.show = 100;      % Frequency of progress displays (in epochs).
net_c.trainParam.epochs = 1000;  % Maximum number of epochs to train.
net_c.trainParam.mc = 0.01;      % Momentum constant.
%net_c.trainParam.mem_reduc = 2;


%Training ...
[net_c,tr] = train(net_c,IP,OP);

b = load('testSine.dat'); % loading the test data

bb = b(:,1);
d = sim(net_c,bb');

sse = (1/length(bb))*((d - b(:,2)')* (d - b(:,2)')');

sse

figure;
plot(b(:,1),b(:,2),'r.');
hold;
plot(b(:,1),d','b.');