Problem solved. So I'm writing an answer to my own question for the benefit of readers who may have a similar problem. The key is with how matlab interprets the time order of the input vector.
Sidebar: The deploy solution option in ntstool executes genFunction. The resulting m-file hard-codes the architecture and delay info, and the indexing appears unnecessarily complicated. But it was useful for troubleshooting my own code.
The problem with my stand-alone NARX code was with my incorrect assumption of the time order of the input vector. Here's an example of part of my simple code that calls my function narxann4:
for time=1+D:Ntimesteps % do for all training set timesteps after lag D
InputVector = Xin(time-inputDelays); %%%NOTE THE ORDER!!!!
Ycalc(time) = narxann4(InputVector',Ycalc(time-feedbackDelays),...
Bias1,WtsInput,WtsContext,Bias2,WtsL2);
end
Notice that the InputVector is in reverse chronological order. For example, if feedbackDelays=1:2 and time=3, then InputVector=[Xin(2) Xin(1)]
Once I figured this out, my simple stand-alone code replicated the maglev closed-loop simulation exactly. Hope this helps somebody.
Cal