Documentation

Tunable Block Parameters and Tunable Global Parameters

To change the behavior of a model, you can tune Simulink® Desktop Real-Time™ block parameters, provided the parameters are tunable. You can change block parameters via the block parameter dialog box, Dashboard blocks, and MATLAB® language. You can create tunable global parameters by using MATLAB variables as value expressions.

In normal or accelerator mode, Simulink transfers the new values to the model that is being simulated. In external mode, Simulink transfers the new values to the real-time application that is running in the kernel mode process.

Tunable Parameters

Simulink Desktop Real-Time defines two kinds of tunable parameters: block parameters and global parameters.

Tunable Block Parameters

A block parameter is a constant expression that you reference in a Simulink block dialog box or by using the MATLAB API. Block parameters are tunable when you set the Default parameter behavior option to Tunable in the Signals and Parameters pane of the Optimization node. When using the MATLAB API, you identify a block parameter by the parameter name and the block path in the model hierarchy.

Suppose that you set the Amplitude parameter of a Signal Generator block to a value of 5/2. You can change the amplitude of the signal generator during simulation by tuning parameter Amplitude in block Signal Generator.

Tunable Global Parameter

A tunable global parameter is a MATLAB variable that you reference in a Simulink block dialog box. You can tune a global parameter or object by using a block dialog box, Dashboard blocks, Property Inspector, Model Explorer, Model Data Editor, or MATLAB language. When using the MATLAB API, you identify a tunable global parameter by the variable name only.

Suppose that you assign to the Amplitude parameter the variable A with the value 4.57. You can change the amplitude of the signal generator during simulation by tuning the value of A in the MATLAB workspace and updating the simulation.

Inlined Parameters

To improve execution efficiency, you can set the Default parameter behavior option to Inlined in the Signals and Parameters pane of the Optimization node.

By default, you cannot tune inlined block parameters. However, you can create a tunable global variable by referencing a MATLAB variable or Simulink.Parameter object in the block dialog box. To make the variable or object tunable, apply a storage class other than Auto to it.

For more information about inlined parameters, see Default parameter behavior (Simulink).

Tuning with External Mode

In external mode, Simulink Desktop Real-Time connects your Simulink model to your real-time application. The block diagram becomes a user interface for the real-time application. You can change a parameter value in a block dialog box or replace the value with a MATLAB variable and tune the variable in the Command Window.

When you change a parameter value in a Simulink model and click OK, Simulink Desktop Real-Time transfers the data to the real-time application and changes the block parameter. You can change only the parameters that do not change the model structure. If you modify the structure, you must recompile the model.

If you change the value of a tunable global parameter, command Simulink to transfer the data from the MATLAB variable to the real-time application by pressing Ctrl+D or clicking Simulation > Update Diagram.

Tuning with MATLAB Language

In Simulink Desktop Real-Time, you can use the MATLAB language command set_param to change the values of block parameters and tunable global parameters. The following code examples use the model sldrtex_model (matlab: open_system(docpath(fullfile(docroot, 'toolbox', 'sldrt', 'examples', 'sldrtex_model')))).

If you are using a literal block parameter value, you access the parameter by a nonempty block path and the parameter name. For example, to change the amplitude of the signal generator:

model = 'sldrtex_model';
sgname = [model '/Signal Generator'];
set_param(sgname, 'Amplitude', '4.57')

If you are replacing a block parameter with a tunable global parameter, you access the parameter by variable name. Suppose that you set Amplitude to the variable A. To change the amplitude of the signal generator:

A = 4.57
set_param('sldrtex_model','SimulationCommand','update')

Related Topics

Was this topic helpful?