1. I am unable to find any documentation on the function newff and what it does. I would be pleased if someone could show me the relevant parts of the documentation...?
2. It is correct for NNs to produce different output for the same input if they are trained separately. This is due to the fact that the initial weights of the neurons are chosen randomly each time. Therefore, the output of your script will be a different NN each time you run it. I think there is a possibility to assign specific initial weights, though.
3. In your code, you do the input shifting by hand. There are tools provided by the NN toolbox to ease that process. Normally, you would do something like the following:
% external input series: humidity
externalInputSeries = tonndata(data(1:end, 5), false, false);
% target (and feedback input!) series: water demand
targetSeries = tonndata(data(1:end, 8), false, false);
% the water demand of the previous day is used as an input
feedbackDelay = 1;
% the average humidity of the previous day is used as an external input
inputDelay = 1;
% use 10 Neurons in the network
hiddenLayerSize = 10;
% create a NARX net
net = narxnet(inputDelays, feedbackDelays, hiddenLayerSize);
% Prepare the Data for Training and Simulation
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,{},targetSeries);
% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivide
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'time'; % Divide up every value
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Choose a Training Function
% For a list of all training functions type: help nntrain
net.trainFcn = 'trainlm'; % Levenberg-Marquardt
% Train the Network
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
% % Test the Network
outputs = net(inputs,inputStates,layerStates);
% show a graphical representation of the NN
view(net);
I do not guarantee that all of the above code is correct, but I've recently solved a similar problem and the above approach worked for me. In my opinion it is nicer than yours since it automates all handling of the test data set.
You can get some inspiration on what is possible by using the graphical NN tool and creating code from it.
Greetings and good luck,
Eike