Inline Parameters

About Inline Parameters

The Inline parameters option (see Inline parameters ) controls how mathematical block parameters appear in code generated from the model. When this optimization is off (the default), a model's mathematical block parameters appear as variables in the generated code. As a result, you can tune the parameters both during simulation and when executing the code.

When Inline parameters is selected, the parameters appear in the generated code as inline numeric constants. This reduces the generated code's memory and processing requirements. However, because the inline parameters appear as constants in the generated code, you cannot tune them during code execution. To ensure that simulation and generated code execution fully correspond, Simulink® prevents you from changing the values of block parameters during simulation when Inline parameters is selected.

    Note:   Simulink ignores tunable parameter specifications in the Model Parameter Configuration dialog box if the model is a referenced model or contains any Model blocks. Do not use this dialog box to configure the storage class of inline model parameters to permit them to be tuned. Instead, see Parameterize Model References for alternate techniques. If you define tunable parameters using Simulink.Parameter objects, you can tune the top model and reference model parameters.

Specify Some Parameters as Noninline

Suppose that you want to take advantage of the Inline parameters optimization while retaining the ability to tune some of your model parameters. You can do this by declaring some parameters as noninline, using either the Model Parameter Configuration Dialog Box or a Simulink.Parameter object. In either case, you must use a workspace variable to specify the value of the parameter.

If you have a Simulink Coder™ license, when compiling a model with the inline parameters option on, Simulink checks to ensure that the data types of the workspace variables used to specify the model's noninline parameters are compatible with code generation. If not, Simulink halts the compilation and displays an error. For more information, see Tunable Workspace Parameter Data Type Considerations.

    Note:   The documentation for the Simulink Coder refers to workspace variables used to specify the value of noninline parameters as tunable workspace parameters. In this context, the term parameter refers to a workspace variable used to specify a parameter as opposed to the parameter itself.

Using a Parameter Object to Specify a Parameter As Noninline

If you use a parameter object to specify a parameter's value (see Use Parameter Objects to Specify Parameter Values), you can also use the object to specify the parameter as noninline. To do this, set the parameter object's CoderInfo.StorageClass property to any value but 'Auto' (the default).

K=Simulink.Parameter;
K.CoderInfo.StorageClass = 'SimulinkGlobal';

If you set the CoderInfo.StorageClass property to any value other than Auto, you should not include the parameter in the tunable parameters table in the Model Parameter Configuration dialog box.

    Note   Simulink halts model compilation and displays an error message if it detects a conflict between the properties of a parameter as specified by a parameter object and the properties of the parameter as specified in the Model Parameter Configuration dialog box.

Was this topic helpful?