Writing S-Functions | ![]() ![]() |
Ask Simulink to reset the solver.
Syntax
Arguments
S
SimStruct representing an S-Function block or a Simulink model.
Description
This macro causes the solver for the current simulation to reinitialize variable step size and zero-crossing computations. This happens only if the solver is a variable-step, continuous solver. (The macro has no effect if the user has selected another type of solver for the current simulation.) An S-function should invoke this macro whenever changes occur in the dynamics of the S-function, e.g., a discontinuity in a state or output, that might invalidate the solver's step-size computations. Otherwise, the solver might take unnecessarily small steps, slowing down the simulation.
Languages
Example
The following example uses this macro to ask Simulink to reset the solver.
static void mdlOutputs(SimStruct *S, int_T tid) { : : <snip> : if ( under_certain_conditions ) { double *x = ssGetContStates(S); /* reset the states */ for (i=0; i<nContStates; i++) { x[i] = 0.0; } /* Ask Simulink to reset the solver. */ ssSetSolverNeedsReset(S); } }
Also see the source code for the Time-Varying Continuous Transfer Function (matlabroot/simulink/src/stvctf.c) for an example of where and how to use this macro.
![]() | ssSetSFcnParamTunable | ssSetStopRequested | ![]() |