Writing S-Functions | ![]() ![]() |
Classes of Problems Solved by S-Functions
S-functions help solve various kinds of problems you might face when working with Simulink and the Real-Time Workshop (Real-Time Workshop). These problems include:
S-functions and S-function routines form an application program interface (API) that allows you to implement generic algorithms in the Simulink environment with a great deal of flexibility. This flexibility cannot always be maintained when you use S-functions with the Real-Time Workshop. For example, it is not possible to access the MATLAB workspace from an S-function that is used with the Real-Time Workshop. However, using the techniques presented in this chapter, you can create S-functions for most applications that work with the generated code from the Real-Time Workshop.
Although S-functions provide a generic and flexible solution for implementing complex algorithms in Simulink, they require significant memory and computation resources. Most often the additional resources are acceptable for real-time rapid prototyping systems. In many cases, though, additional resources are unavailable in real-time embedded applications. You can minimize memory and computational requirements by using the Target Language Compiler technology provided with the Real-Time Workshop to inline your S-functions.
![]() | Writing S-Functions for Real-Time Workshop | Types of S-Functions | ![]() |