MATLAB: Lag Space in NARX NN

Deep Learning Toolboxnarxneural networknn toolbox

I'm trying to model a MIMO sytem (two inputs and two outputs) with a NARX neural net. My problem is that no matter which combination of past inputs and outputs I use, I keep getting a poor performance when simulating it in closed loop.
I've been reading about using the correlation functions to get a good estimation of the needed lags by plotting the results of these functions but I don't quite understand how to use them. I would really appreciate it, if somebody could explanin it to me or post some code to obtain the lags.

Best Answer

Many code examples have been posted. Search on
greg nncorr narxnet
Hope this helps
Thank you for formally accepting my answer
Greg