Skip to Main Content Skip to Search
Product Documentation

ssSetSolverNeedsReset - Ask the Simulink engine to reset the solver

Syntax

void ssSetSolverNeedsReset(SimStruct *S)

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

C, C++

Example

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. */ 
		ssSetSolverNeedsReset(S); 
	}
}

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.

See Also

ssIsVariableStepSolver

  


Related Products & Applications

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

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