Real-Time Workshop | ![]() ![]() |
Storage of Nontunable Parameters
By default, block parameters are not tunable in the generated code. In the default case, Real-Time Workshop has control of parameter storage declarations and the symbolic naming of parameters in the generated code.
Nontunable parameters are stored as fields within rtP, a model-specific global parameter data structure. Real-Time Workshop initializes each field of rtP to the value of the corresponding block parameter at code generation time.
When the Inline parameters option is on, block parameters are evaluated at code generation time, and their values appear as constants in the generated code. (A vector parameter, however, may be represented as an array of constants within rtP.) Use the Generate scalar inline parameters as pull-down menu on the General code appearance category pane to choose whether to represent such parameters as literals (numeric constants) or as macros (#define
constants) in the generated code.
As an example of nontunable parameter storage, consider this model.
The workspace variable Kp
sets the gain of the Gain1
block.
Assume that Kp
is nontunable, and has a value of 5.0. Table 5-1 shows the variable declarations and the code generated for Kp
in the noninlined and inlined cases.
Notice that the generated code does not preserve the symbolic name Kp
. The noninlined code represents the gain of the Gain1
block as rtP.Gain1_Gain.
![]() | Parameters: Storage, Interfacing, and Tuning | Tunable Parameter Storage | ![]() |