In the NEWFFTD function, ID defines the vector of input delays. If you want the network to predict the target at time t given inputs at times t-1, t-2, and t-3 then ID would be [1 2 3].
If you want the target at time t to be predicted at times t, t-2, and t-4 then ID would be [0 2 4].
You can use PREMNMX, POSTMNMX, and TRAMNMX to normalize data to min and max of -1 and +1. They are described in their help comments and also on page 5-44 of the User's Guide.
Sequences are represented with row cell arrays. The following example may help you determine how to format your own prediction problem.
Let us say we have a sequence Z as defined below:
t = 0, Z(:,t+1) = [0; 1];
t = 1, Z(:,t+1) = [-1; 0];
t = 2, Z(:,t+1) = [-1; 1];
t = 3, Z(:,t+1) = [0; 0];
t = 4, Z(:,t+1) = [1; -1];
t = 5, Z(:,t+1) = [0; -1];
We would like the network to predict Z(t) given Z(t-1), Z(t-2) and Z(t-3).
We can define this problem with three row cell arrays. They are:
Pi - the initial inputs for which the network will not have a target
P - the inputs for which the network will have a target
T - the targets
In this case two initial inputs must be presented before the network can predict anything:
Pi= {Z(0) Z(1)} = {[0;1] [-1;0]} = Pi = con2seq(Z(:,1:2));
The network will then be presented with Z(2) through Z(4)...
P = {Z(2) Z(3) Z(4)} = {[-1; 1] [0;0] [1;-1]} = con2seq(Z(:,3:5));
...and will be expected to respond with Z(3) through Z(5).
T = {Z(3) Z(4) Z(5)} = {[0;0] [1;-1] [0;-1]} = T = con2seq(Z(:,4:6));
Note that we would like the network to predict Z(t) given Z(t-1)..Z(t-3). This is equivalent to predicting T{i} given P{i}, P{i-1}, and P{i-2} so ID will equal [0 1 2].
Here a network is created that can do that. It has a two-element input whose values range from -1 to 1. It has input delays of 0, 1, and
2. It has 5 hidden neurons and 1 output.
net = newfftd(minmax(Z),[0 1 2],[5 2]);
It is then trained with P, Pi, and T as follows:
net.trainparam.epochs=500;
net = train(net,P,T,Pi);
The complete code follows:
Z = [ 0 -1 -1 0 1 0 ;
1 0 1 0 -1 -1 ];
Pi = con2seq(Z(:,1:2));
P = con2seq(Z(:,3:5));
T = con2seq(Z(:,4:6));
net = newfftd(minmax(Z),[0 1 2],[5 2]);
net.trainparam.epochs=500;
net = train(net,P,T,Pi);
Y=sim(net,P,Pi);
[Y{:}]-[T{:}]
For more neural network examples, visit the MATLAB Central File Exchange at https://www.mathworks.com/matlabcentral/
