Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

mdlDerivatives - Compute the S-function's derivatives

Required

No

C Syntax

#define MDL_DERIVATIVES
void mdlDerivatives(SimStruct *S)

C Arguments

S

SimStruct representing an S-Function block.

M Syntax

Derivatives(s)

M Arguments

s

Instance of Simulink.MSFcnRunTimeBlock class representing the Level-2 M-File S-Function block

Description

The Simulink engine invokes this optional method at each time step to compute the derivatives of the S-function's continuous states. This method should store the derivatives in the S-function's state derivatives vector. In a C MEX S-function, use ssGetdX to get a pointer to the derivatives vector. In a Level-2 M-file S-function, use the run-time object's Derivatives method.

Each time the mdlDerivatives routine is called, it must explicitly set the values of all derivatives. The derivative vector does not maintain the values from the last call to this routine. The memory allocated to the derivative vector changes during execution.

C Example

For a C MEX S-function example, see matlabroot/toolbox/simulink/simdemos/simfeatures/src/csfunc.c.

M Example

For a Level-2 M-file S-function example, see matlabroot/toolbox/simulink/simdemos/simfeatures/ msfcn_limintm.m.

Languages

C, C++, M

See Also

ssGetdx

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS