Real-Time Workshop | ![]() ![]() |
Parameter Objects
This section discusses how to use parameter objects in code generation.
Configuring Parameter Objects for Code Generation
In configuring parameter objects for code generation, you use the following code generation and parameter object properties:
Note
If Inline parameters is off (the default), the RTWInfo.StorageClass parameter object property is ignored in code generation.
|
Effect of Storage Classes on Code Generation for Parameter Objects
Real-Time Workshop generates code and storage declarations based on the RTWInfo.StorageClass
property of the parameter object. The logic is as follows:
'Auto'
(the default), the parameter object is inlined (if possible), using the Value
property.
'Auto'
, the parameter object is handled as a tunable parameter.
See Table 5-6 for examples of code generated for each possible setting of RTWInfo.StorageClass
.
Example of Parameter Object Code Generation
In this section, we use the Gain block computations of the model shown in the figure below as an example of how Real-Time Workshop generates code for a parameter object.
Figure 5-5: Model Using Parameter Object Kp As Block Parameter
In this model, Kp
sets the gain of the Gain1
block.
To configure a parameter object such as Kp
for code generation:
Simulink.Parameter
. In this example, the parameter object is an instance of the example class SimulinkDemos.Parameter, which is provided with Simulink. For the definition of SimulinkDemos.Parameter, see the directory matlabroot
/toolbox/simulink/simdemos/@SimulinkDemos
.
Parameter
.
Table 5-6 shows the variable declarations for Kp
and the code generated for the Gain block in the model shown in Figure 5-5, with Inline parameters on. (Due to expression folding optimizations, the gain computation is included in the output computation.) An example is shown for each possible setting of RTWInfo.StorageClass
.
![]() | Simulink Data Objects and Code Generation | Parameter Object Configuration Quick Reference Diagram | ![]() |