clc
clear
[num,txt] = xlsread('Monthly_Shiraz data');% It Reads data and strings 
%from the excel file

Input = num(:,3:5)'; % Monthly Tmean, Sunshine and wind velocity
Evap = num(:,6)'; % Monthly Evaporation as target

Input_Eval = Input(:,end-9:end);
Input(:,end-9:end) = [];

Evap_Eval = Evap(:,end-9:end);
Evap(:,end-9:end) = [];

inputs = Input;
targets = Evap;

trainFcn = 'trainlm';  % Levenberg-Marquardt

hiddenLayerSize = 12;

net = fitnet(hiddenLayerSize,trainFcn);

net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;

[net,tr] = train(net,inputs,targets);

Output = net(inputs);
e = gsubtract(targets,Output);
performance = perform(net,targets,Output);

figure, plotregression(targets,Output)
R = corr(targets(:),Output(:))

figure
testInd = tr.testInd;
tstOutputs = net(inputs(:,testInd));
tsttargets = targets(testInd);
plotregression(tsttargets,tstOutputs)

Output_Eval = net(Input_Eval);
 
plotregression(Evap_Eval,Output_Eval)




