MATLAB: How to Create Simulink Block for NARX Neural Network and Predict Multiple Time Steps Ahead

blockclosedloopmultiplenarxoutputsimulinksteps;

How can I create a Simulink block for a NARX Neural Network that predicts multiple time steps ahead?

Best Answer

Here is an analogous solution to a close loop neural network in Simulink that predicts multiple output steps, like the MATLAB example here:
I used the example from "setsiminit" to create this example for you, which is slightly modified:
% This part of the example is nearly identical
[x,t] = simplenarx_dataset;
xnew = x(81:100);
x = x(1:80);
t = t(1:80);
net = narxnet(1:2,1:2,20);
[Xs,Xi,Ai,Ts] = preparets(net,x,{},t);
net = train(net,Xs,Ts,Xi,Ai);
[Y,Xf,Af] = net(Xs,Xi,Ai);
[netc,Xic,Aic] = closeloop(net,Xf,Af);
% Show the predicted 20 steps in MATLAB
y2 = netc(xnew,Xic,Aic)
% Create a Simulink block
[sysName,netName] = gensim(netc,'InputMode','Workspace',...
'OutputMode','WorkSpace','SolverMode','Discrete');
setsiminit(sysName,netName,netc,Xic,Aic,1);
x1 = nndata2sim(x,1,1);
This will create a model in Simulink that outputs 20 values per Simulink time-step.
Related Question