Documentation Center

  • Trial Software
  • Product Updates

S-Function Limitations

The following table summarizes the major limitations of the different types of S-functions.

ImplementationLimitations
Level-1 MATLAB® S-functionDoes not support the majority of S-function features. See the S-Function Features section for information on what features a Level-1 MATLAB S-function does support.
Level-2 MATLAB S-functions
  • Does not support bus input and output signals.

  • Cannot incorporate legacy code during simulation, only during code generation through a TLC file.

Handwritten C MEX S-functionSupports model referencing with some limitations. See S-Functions with Model Referencing and S-Function Limitations in Model Referencing Limitations.
S-Function Builder
  • Generates S-function code using a wrapper function which incurs additional overhead.

  • Does not support the following S-function features:

    • Work vectors

    • Port-based sample times

    • Multiple sample times or a nonzero offset time

    • Dynamically-sized input and output signals for an S-function with multiple input and output ports

    Note:   S-functions with one input and one output port can have dynamically-sized signals

Legacy Code Tool
  • Generates C MEX S-functions for existing functions written in C or C++ only. The tool does not support transformation of MATLAB or Fortran functions.

  • Can interface with C++ functions, but not C++ objects.

  • Does not support simulating continuous or discrete states.

  • Does not support use of function pointers as the output of the legacy function being called.

  • Always sets the S-function's flag for direct feedthrough (sizes.DirFeedthrough) to true.

  • Supports only the continuous, but fixed in minor time step, sample time and offset option.

  • Supports complex numbers, but only with Simulink® built-in data types.

  • Does not support the following S-function features:

    • Work vectors, other then general DWork vectors

    • Frame-based input and output signals

    • Port-based sample times

    • Multiple block-based sample times

Was this topic helpful?