Skip to Main Content Skip to Search
Product Documentation

S-Functions Using Variable-Size Signals

Demo of Level-2 MATLAB S-Function with Variable-Size Signals

Both Level-2 MATLAB S-Functions and C S-Functions support variable-size signals when you set the DimensionMode for the output port to Variable. You also need to consider the current dimension of the input and output signals in the input and output update methods.

To open this demo model, in the MATLAB Command Window, type:

msfcndemo_varsize

The Enabled subsystem includes a Level-2 MATLAB S-Function which demonstrates how to implement a block that holds its states until reset. Because this block contains states and delays the input signal, the input size can change only when a reset occurs.

The Expand block is a Level-2 MATLAB S-Function that takes a scalar input and outputs a vector of length indicated by its input value. The output is by 1:n where n is the input value.

Demo of C S-Function with Variable-Size Signals

To open this demo model, in the MATLAB Command Window, type:

sfcndemo_varsize

The enabled subsystems have two S-Functions:

  


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