User`s guide
4 Guidelines for Writing C MEX S-Functions
4-24
mxGetPr MATLAB API function. This results in a slight increase in
performance.
mdlRTW Usage
The Real-Time Workshop calls the mdlRTW routine while it (the Real-Time
Workshop) generates the
model.rtw file. You can add information to the
model.rtw file about the mode in which your S-function block is operating to
produce optimal code for your Simulink model.
This example adds the following information to the
model.rtw file:
• Parameters — these are items that can be modified during execution by
external mode. In this example, the
XData and YData S-function parameters
can change during execution and are written using the function
ssWriteRTWParameters.
• Parameter settings — t hese are items that do not change during execution.
In this case the
XDataEvenlySpaced S-function parameter cannot change
during execution (
ssSetSFcnParamNotTunable was s pecified for it in
mdlInitializeSizes). This example writes it out as a parameter setting
(
XSpacing) using the function ssWriteRTWParamSettings.
Example Model
Before examini ng the S-function and the inlined TLC file, consider the
generated code f or the following model.