Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

C-Mex S function - storing values between timesteps?

Asked by Craig on 9 Dec 2012

Probably a noobish question...

For example, would it be possible to write a C mex S-function that returned the input value from three timesteps ago?

I ask this because I'd like to write a neural network as a C mex and would like weights etc to be stored between iterations.

Best regards,

Craig

0 Comments

Craig

Products

1 Answer

Answer by TAB on 10 Dec 2012
Accepted answer

You can create the discrete states in your s-function and save the input values in state variables in mdlupdate() function. You can output the values of these discrete variables (which are nothing but delayed values) in mdlOutput() function.

See this example for discrete state s-function.

0 Comments

TAB

Contact us