Writing S-Functions    

Example

The example file, matlabroot/simulink/src/sfun_timestwo_for.for, implements an S-function that multiplies its input by two.

A Level 1 S-function's input/output is limited to using the REAL*8 data type, (DOUBLE PRECISION), which is equivalent to a double in C. Of course, the internal calculations can use whatever data types you need.

To see how this S-function works, type

at the MATLAB prompt and then run the model.


 Creating Level 1 Fortran S-Functions Inline Code Generation Example