| Writing S-Functions | ![]() |
Defining S-Function Block Characteristics
For Simulink to recognize an M-file S-function, you must provide it with specific information about the S-function. This information includes the number of inputs, outputs, states, and other block characteristics.
To give Simulink this information, call the simsizes function at the beginning of mdlInitializeSizes.
sizes = simsizes;
This function returns an uninitialized sizes structure. You must load the sizes structure with information about the S-function. The table below lists the sizes structure fields and describes the information contained in each field.
After you initialize the sizes structure, call simsizes again.
sys = simsizes(sizes);
This passes the information in the sizes structure to sys, a vector that holds the information for use by Simulink.
| S-Function Outputs | A Simple M-File S-Function Example | ![]() |