Main Content

Custom Code and Hand Coded Blocks using the S-function API

This library launches examples of different types of Simulink® S-functions. Simulink S-functions allow you to extend Simulink with new hand coded blocks, interface to custom external code, and create live interfaces to other programs. Models containing S-functions in the following programming languages can be accessed through this demonstration: C, C++, M and Fortran.

Each example contains a model that exercises an S-function block and a link for editing the S-function code. You can also access the main S-function file by using the Edit... button on the S-function block dialog (which is under a mask in some of the models; use the "Look Under Mask" context menu item to access the S-function dialog in this situation).

Additionally, the S-function Builder block is a masked version of the S-function block that includes an easy to use editor that automatically builds an S-function out of a core algorithm that you enter into it along with input, output, and parameter attributes. By default, the S-function Builder also creates a TLC file for use with Simulink® Coder™ and Embedded Coder™.