Writing S-Functions    
mdlInitializeSampleTimes

Specify the sample rates at which this S-function operates.

Syntax

Arguments

S
   SimStruct representing an S-Function block.

Description

This method should specify the sample time and offset time for each sample rate at which this S-function operates via the following paired macros

where sampleTimeIndex runs from 0 to one less than the number of sample times specified in mdlInitializeSizes via ssSetNumSampleTimes.

If the S-function operates at one or more sample rates, this method can specify any of the following sample time and offset values for a given sample time:

The uppercase values are macros defined in simstruc.h.

If the S-function operates at one rate, this method can alternatively set the sample time to one of the following sample/offset time pairs.

If the number of sample times is 0, Simulink assumes that the S-function inherits its sample time from the block to which it is connected, i.e., that the sample time is

This method can therefore return without doing anything.

Use the following guidelines when specifying sample times.

If this function has no intrinsic sample time, it should set its sample time to inherited according to the following guidelines:

The S-function should use the ssIsSampleHit or ssIsContinuousTask macros to check for a sample hit during execution (in mdlOutputs or mdlUpdate). For example, if the block's first sample time is continuous, the function can use the following code fragment to check for a sample hit.

If the function wants to determine whether the third (discrete) task has a hit, it can use the following code fragment.

Languages

C

See Also

mdlSetInputPortSampleTime, mdlSetOutputPortSampleTime


  mdlInitializeConditions mdlInitializeSizes