Real-Time Workshop User's Guide | ![]() ![]() |
The Real-time Workshop supports the use of tunable variables in expressions. An expression that contains one or more tunable parameters is called a tunable expression.
Currently, there are certain limitations on the use of tunable variables in expressions. When an expression described below as not supported is encountered during code generation, a warning is issued and a nontunable expression is generated in the code. The limitations on tunable expressions are:
The rules applying to each category are as follows:
Note The "dot" (structure membership) operator is not supported. This means that expressions that include a structure member are not tunable. |
Tunable Expressions in Masked Subsystems
Tunable expressions are allowed in masked subsystems. You can use tunable parameter names or tunable expressions in a masked subsystem dialog. When referenced in lower-level subsystems, such parameters remain tunable.
As an example, consider the masked subsystem depicted below. The masked dialog variable k
sets the gain parameter of theGain
.
Suppose that the base workspace variable b
is declared tunable with SimulinkGlobal(Auto)
storage class. Figure 3-11 shows the tunable expression b*3
in the subsystem's mask dialog.
Figure 3-11: Tunable Expression in Subsystem Mask Dialog
The Real-Time Workshop produces the following output computation for theGain
.
/* Gain Block: <S1>/theGain */ rtb_temp0 *= (rtP.b * 3.0);
Note that b
is represented as a member of the global parameters structure, rtP
.
Limitations of Tunable Expressions in Masked Subsystems. Expressions that include variables that were declared or modified in mask initialization code are not tunable.
As an example, consider the subsystem above, modified as follows:
t = 3 * k;
k
of the myGain
block is 4 + t
.b = 2
. The expression b * 3
is plugged into the mask dialog as in Figure 3-11.Since the mask initialization code can only run once, k
is evaluated at code generation time as
4 + (3 * (2 * 3) )
The Real-Time Workshop inlines the result. Therefore, despite the fact that b
was declared tunable, the code generator produces the following output computation for theGain
.
/* Gain Block: <S1>/theGain */ rtb_temp0 *= (22.0);
![]() | Using the Model Parameter Configuration Dialog | Tunability of Linear Block Parameters | ![]() |