Writing S-Functions    

Examples of M-File S-Functions

The easiest way to understand how S-functions work is to look at examples. This section starts off with a s simple example (timestwo) that has no states. Most S-Function blocks require the handling of states, whether continuous or discrete. The sections that follow discuss four common types of systems you can model in Simulink using S-functions:

All examples are based on the M-file S-function template found in sfuntmpl.m.


  Processing S-Function Parameters Simple M-File S-Function Example