Ask the Simulink engine to reset the solver


void ssSetSolverNeedsReset(SimStruct *S)



SimStruct representing an S-Function block or a Simulink® model.


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.

    Note   If a change in the dynamics of the S-function necessitates reinitializing its continuous states, the S-function should reinitialize the states before invoking this macro to ensure accurate computation of the next step size.


C, C++


The following example uses this macro to ask the Simulink engine 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 the Simulink engine to reset the solver. */ 

Also see the source code for the Time-Varying Continuous Transfer Function (stvctf.c) for an example of where and how to use this macro.

Introduced before R2006a

Was this topic helpful?