| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
You can create custom blocks whose properties and behaviors are defined by M-file functions called M-file S-functions. The Level-2 M-file S-function application programming interface (API) allows you to create blocks that have many of the features and capabilities of Simulink built-in blocks, including:
Multiple input and output ports
1-D, 2-D, and n-D input and output signals
All data types supported by the Simulink software
Real or complex signals
Frame-based signals
Multiple sample rates
User-defined data and work vectors
Tunable and run-time parameters
For information on how to write a Level-2 M-file S-functions, see Writing Level-2 M-File S-Functions.
You can generate code for Level-2 M-file S-functions if they are inlined. See Inlining S-Functions in the Real-Time Workshop Target Language Compiler documentation for more information.
Note This version of the Simulink software also supports a predecessor API known as the Level-1 M-file S-function. This ensures that you can simulate models developed with earlier releases that use Level-1 M-file S-functions in their S-Function blocks (see Maintaining Level-1 M-File S-Functions). Level-1 M-file S-functions support a much smaller subset of the S-function API then Level-2 M-file S-functions, and their features are limited compared to built-in blocks. Use the Level-2 API, not the Level-1 API, to develop new M-file S-functions. |
![]() | Writing S-Functions in M | Writing Level-2 M-File S-Functions | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |