Documentation Center

  • Trial Software
  • Product Updates

Contents

mdlGetTimeOfNextVarHit

Specify time of the next sample time hit

Required

No

Languages

C, C++

Syntax

#define MDL_GET_TIME_OF_NEXT_VAR_HIT
void mdlGetTimeOfNextVarHit(SimStruct *S)

Arguments

S

SimStruct representing an S-Function block.

Description

The Simulink® engine invokes this optional method at every major integration step to get the time of the next sample time hit. This method should set the time of next hit, using ssSetTNext. The time of the next hit must be greater than the current simulation time as returned by ssGetT. The S-function must implement this method if it operates at a discrete, variable-step sample time.

For Level-2 MATLAB® S-functions, use a sample time of -2 to specify a variable sample time. The S-function's output method should then update the NextTimeHit property of the instance of the Simulink.MSFcnRunTimeBlock class representing the S-Function block to set the time of the next sample time hit. See /msfcn_vs.mmsfcn_vs.m for an example.

For Level-1 MATLAB S-functions, a flag of 4 is passed to the S-function when the next sample time hit needs to be calculated.

    Note   The time of the next hit can be a function of the input signals.

Example

  static void mdlGetTimeOfNextVarHit(SimStruct *S)
  {
    time_T offset = getOffset();
  	time_T timeOfNextHit = ssGetT(S) + offset;
  	ssSetTNext(S, timeOfNextHit);
  }
Was this topic helpful?