User`s guide

3 Writing S-Functions As C-MEX files
3-18
Alternate Calling Structure for External Mode
When running Simulink in external mode, the calling sequence for S-function
routines changes. This picture shows the correct sequence for external mode:
Figure 3-3: S-Function Calling Sequence when Simulink Runs in External
Mode
Simulink calls mdlRTW once when it enters external mode and again each
time a parameter changes or when you select
Update Diagram under your
model’s
Edit menu.
Note Running Simulink in external mode requires the Real-Time Workshop.
For more information about external mode, see the Real-Time Workshop
User’s Guide.
mdlRTW For code generation only
p. 3-54
mdlTerminate
p. 3-53
mdlSetInputPortWidth/mdlSetOutputPortWidth
mdlInitializeSizes
mdlInitializeSampleTimes
mdlSetWorkWidths
mdlStart
p. 3-28
p. 3-35
p. 3-46
p. 3-48
p. 3-36
mdlSetInputPortSampleTime/mdlSetOutputPortSampleTime
p. 3-33
mdlInitializeConditions
p. 3-48
External mode
parameter change loop