Real-Time Workshop | ![]() ![]() |
Tunable Parameters in Generated S-Functions
You can utilize tunable parameters in generated S-functions in two ways:
auto
storage class in the source model become tunable parameters of the generated S-function.
Note that these parameters do not become part of a generated rtP
parameter data structure, as they would in code generated from other targets. Instead, the generated code accesses these parameters via MEX API calls such as mxGetPr
or mxGetData
. Your code should access these parameters in the same way.
For further information on MEX API calls, see Writing S-Functions and External Interfaces/API in the MATLAB online documentation.
S-Function blocks created via the S-function target are automatically masked. The mask displays each tunable parameter in an edit field. By default, the edit field displays the parameter by variable name, as in the following example.
You can choose to display the value of the parameter rather than its variable name. To do this, select Use Value for Tunable Parameters in the Options section.
When this option is chosen, the value of the variable (at code generation time) is displayed in the edit field, as in the following example.
![]() | Sample Time Propagation in Generated S-Functions | Automated S-Function Generation | ![]() |