Writing S-Functions | ![]() ![]() |
Set the sample time of an input port that inherits its sample time from the port to which it is connected.
Syntax
void mdlSetInputPortSampleTime(SimStruct *S, int_T port, real_T sampleTime, real_T offsetTime)
Arguments
S
Simstruct representing an S-function block.
port
offsetTime
port
Description
Simulink invokes this method with the sample time that port
inherits from the port to which it is connected. If the inherited sample time is acceptable, this method should set the sample time of port
to the inherited time, using ssSetInputPortSampleTime. If the sample time is unacceptable, this method should generate an error via ssSetErrorStatus. Note that any other inherited input or output ports whose sample times are implicitly defined by virtue of knowing the sample time of the given port can also have their sample times set via calls to ssSetInputPortSampleTime
or ssSetOutputPortSampleTime
.
When inherited port based sample times are specified, we are guaranteed that the sample time will be one of the following:.
Sample Time |
Offset Time |
|
Continuous |
0.0 |
0.0 |
Discrete |
period |
offset |
where 0.0 < period < inf
and 0.0 <= offset < period
. Constant, triggered, and variable step sample times are not be propagated to S-functions with port- based sample times.
Generally mdlSetInputPortSampleTime
is called once with the input port sample time. However, there can be cases where this function will be called more than once. This happens when the simulation engine is converting continuous sample times to continuous but fixed in minor steps sample times. When this occurs, the original values of the sample times specified in mdlInitializeSizes
will be restored before calling this method again.
The final sample time specified at the port may be different from (but equivalent to) the sample time specified by this method. This occurs when:
[0.2499999999999, 0]
to [0.25, 0]
.The S-function can examine the final sample times in mdlInitializeSampleTimes.
Languages
See Also
ssSetInputPortSampleTime, ssSetOutputPortSampleTimes, mdlInitializeSampleTimes
![]() | mdlSetInputPortFrameData | mdlSetInputPortWidth | ![]() |