MATLAB: Is it possible to generate code from a Matlab level 2 S-function containing ANN tools

anncode generationonline learningsimulink

I followed the instructions here: https://se.mathworks.com/matlabcentral/answers/101260-is-it-possible-to-use-simulink-to-train-a-neural-network and created a S-func to use ANN tools in Simulink along with online learning.
Now I would like to know how I can generate code from this, if possible?
I have used the ANN toolbox inside the S-func with functions such as train..

Best Answer

"Neural Network Toolbox
You can use genFunction in the Neural Network Toolbox™ to generate a standalone MATLAB function for a trained neural network. You can generate C/C++ code from this standalone MATLAB function. To generate Simulink® blocks, use the genSim function. See Deploy Trained Neural Network Functions (Neural Network Toolbox)."
To emphasize: you cannot code generate for train(): you can only code generate the result of having already trained.
Related Question