This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Set the sample time of an output port that inherits its sample time from the port to which it is connected




C, C++


void mdlSetOutputPortSampleTime(SimStruct *S, int_T port,
 real_T sampleTime, real_T offsetTime)



SimStruct representing an S-Function block.


Index of a port.


Inherited sample time for port.


Inherited offset time for port.


The Simulink® engine calls this method with the sample time that port inherits from the port to which it is connected.

For C MEX S-functions, if the inherited sample time is acceptable, this method should set the sample time of port to the inherited sample time and offset time, using ssSetOutputPortSampleTime and ssSetOutputPortOffsetTime. If the sample time is unacceptable, this method generates an error via ssSetErrorStatus. This method is only valid for simulation, and must be enclosed in a #if defined(MATLAB_MEX_FILE) statement.

This method can set the sample time of any other input or output port whose sample time derives from the sample time of port, using ssSetInputPortSampleTime or ssSetOutputPortSampleTime in C MEX S-functions.

Normally, sample times are propagated forward; however, if sources feeding this block have inherited sample times, the engine might choose to back-propagate known sample times to this block. When back-propagating sample times, this method is called in succession for all inherited output port signals.

See mdlSetInputPortSampleTime for more information about when this method is called.

Introduced before R2006a