Writing S-Functions

Chapter 1
Overview of S-Functions


Introduction

S-functions (system-functions) provide a powerful mechanism for extending the capabilities of Simulink®. The introductory sections of this chapter describe what an S-function is and when and why you might use one. This chapter then presents a comprehensive description of how to write your own S-functions.

S-functions allow you to add your own blocks to Simulink models. You can create your blocks in MATLAB®, C, C++, Fortran, or Ada. By following a set of simple rules, you can implement your algorithms in an S-function. After you have written your S-function and placed its name in an S-Function block (available in the Functions & Tables block library), you can customize the user interface by using masking.

S-functions can be used with the Real-Time Workshop. You can also customize the code generated by the Real Time Workshop® for S-functions by writing a Target Language CompilerTM (TLC) file. See the Target Language Compiler Reference Guide and the Real-Time Workshop User's Guide for more information.


 What Is an S-Function?