| Writing S-Functions | ![]() |
Processing Frame-Based Signals
This section explains how to create an S-function that accepts and/or produces frame-based signals. See "Frame-Based Signals" in the "Working with Signals" section of the Signal Processing Blockset documentation for a comprehensive discussion of the use of frame-based signals in Simulink models.
| Note Simulating a model containing the S-function that you develop requires a Signal Processing Blockset license. |
To accept or produce frame-based signals, an S-function must perform the following tasks:
mdlInitializeSizes callback method must set the port frame status to FRAME_YES, FRAME_NO, or FRAME_INHERITED for each of the S-function's I/O ports, using the ssSetInputPortFrameData and ssSetOutputPortFrameData functions.
mdlSetInputPortFrameData callback method. Simulink passes the frame status that it assignes to the port, based on frame signal propagation rules, as an argument to this callback method. The callback method should in turn use the ssSetInputPortFrameData function to set the port to the assigned status if it is acceptable or signal an error if it is not. If the frame status of other ports of the S-function depend on the status inherited by one of its input ports, the callback method can also use ssSetInputPortFrameData to set the frame status of the other ports based on the status that the input port inherits.
mdlOutputs method should include code to process the signals.
mdlInitializeSizes or mdlSetInputPortDimensionInfo and mdlSetOutputPortDimensionInfo callback methods. Note that frame-based signals must be dimensioned as 2-D arrays.
See the frame-based A/D converter S-function example (sfun_frmad.c) for an example of how to create a frame-based S-function.
| Function-Call Subsystems | Handling Errors | ![]() |
© 1994-2005 The MathWorks, Inc.