Skip to Main Content Skip to Search
Product Documentation

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

Required

No

C Syntax

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

C Arguments

S

SimStruct representing an S-Function block.

port

Index of a port.

sampleTime

Inherited sample time for port.

offsetTime

Inherited offset time for port.

MATLAB Syntax

SetOutputPortSampleTime(s, port, time)

MATLAB Arguments

s

Instance of Simulink.MSFcnRunTimeBlock class representing the S-Function block.

port

Integer value specifying the index of port whose sampling mode is to be set.

time

Two-element array, [period offset], that specifies the period and offset of the times that this port produces output.

Description

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.

For Level-2 MATLAB S-functions, if the inherited sample time is acceptable, this method sets the sample time and offset time using the line

s.OutputPort(port).SampleTime = time;

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, or setting the SampleTime property of the Simulink.BlockPortData object associated with the port in Level-2 MATLAB 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.

Languages

C, C++, MATLAB

See Also

ssSetOutputPortSampleTime, ssSetErrorStatus, ssSetInputPortSampleTime, ssSetOutputPortSampleTime, mdlSetInputPortSampleTime, Simulink.MSFcnRunTimeBlock, Simulink.BlockPortData

  


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