Main Content

ParameterTuner

Create parameter tuner component for App Designer component in instrument panel UI

Description

example

hPTuner = slrealtime.ui.tool.ParameterTuner(hFigure) creates a parameter tuner component for an App Designer component on an instrument panel uifigure figure. After connecting the parameter tuner to an App Designer component (such as a knob), the App Designer component gets or sets data in the real-time application in the same manner as Simulink Real-Time components available in the App Designer. The parameter tuner component pulls the current parameter value from the target when:

  • The instrument panel first starts and an application is loaded on the selected target computer.

  • The target selected by the instrument panel changes and an application is loaded on the selected target computer.

  • An application is loaded on the selected target computer.

  • The parameter is changed from an external source, such as the command line, Explorer, other instrument panels on the selected target computer.

If the current value of the parameter is changed from an external source and is invalid for the Parameter Tuning component (for example, it is out of range of the knob), the Parameter Tuning component displays a warning icon covering the component. Changing the parameter from an external source to some valid value for the component removes the warning icon.

For information about parameter tuner properties, see slrealtime.ui Properties.

Examples

collapse all

Create an App Designer component and connect it to a block in a real-time application for parameter tuning. Changing the value of the component pushes the value to the real-time application on the target computer.

% Create figure 
hFig = uifigure(); 
% Create a hKnob 
hKnob = uiknob(hFig); 
% Create Parameter Tuning object 
hParamTuner = slrealtime.ui.tool.ParameterTuner(hFig); 
hParamTuner.Component = hKnob; 
hParamTuner.BlockPath = 'testmodel/Constant6'; 
hParamTuner.ParameterName = 'Value';

In Connect App Designer Component for Parameter Tuning, the code shows how to connect the ParameterTuner component to a value on a block. Instead, you can use slightly different code to connect the ParameterTuner component to a variable or parameter in the workspace. In the code for the component, the BlockPath is empty, and the ParameterName is the parameter name instead of the property of the block to tune. The syntax for the code could be:

% Create Parameter Tuning object
hParamTuner = slrealtime.ui.tool.ParameterTuner(hFig);
hParamTuner.Component = hKnob;
hParamTuner.BlockPath = '';
hParamTuner.ParameterName = 'myParameter'; 

The changeComponentValue function enables you to change the value of the parameter that is connected to the ParameterTuner component. Using this function to change the value of the component pushes the value to the real-time application on the target computer.

% Create figure 
hFig = uifigure(); 
% Create a hKnob 
hKnob = uiknob(hFig); 
% Create Parameter Tuning object 
hParamTuner = slrealtime.ui.tool.ParameterTuner(hFig); 
hParamTuner.Component = hKnob; 
hParamTuner.BlockPath = 'slrt_ex_osc/Signal Generator'; 
hParamTuner.ParameterName = 'Amplitude';
changeComponentValue(hParamTuner,2)
getparam(tg, 'slrt_ex_osc/Signal Generator', 'Amplitude')
ans =

     2

Input Arguments

collapse all

The hFigure argument identifies the uifigure to which you are adding the UI component.

Example: hFig = uifigure()

Data Types: function_handle

Output Arguments

collapse all

The hPTuner argument is the handle to the parameter tuner component that you create for the App Designer component.

Version History

Introduced in R2021b