Main Content

uisimvartuner

R2026b

Create variable tuner UI component in app

Since R2024a

    Description

    vartnr = uisimvartuner creates a variable tuner in a new figure and returns the VariableTuner object. MATLAB® calls the uifigure function to create the figure.

    vartnr = uisimvartuner(p) creates a variable tuner in the specified parent container. The parent can be a Figure object or one of its child containers.

    vartnr = uisimvartuner(___,Name=Value) creates a variable tuner with properties specified by one or more name-value arguments.

    example

    Examples

    collapse all

    Add a variable tuner component to an app. Then, connect the component to a Simulation object.

    Create a variable tuner inside a panel in a UI figure.

    f = uifigure(Name="MyFigure");
    panel = uipanel(f);
    vartnr = uisimvartuner(panel);

    To connect the variable tuner to a simulation, specify the Simulation property. When you edit variable values, the tuner updates the variable values in the simulation.

    mdl = "MyModel";
    sm = simulation(mdl);
    vartnr.Simulation = sm;

    After creating the variable tuner, set the VariablesFilter property to display only specific variables.

    Create a variable tuner inside a panel in a UI figure.

    f = uifigure(Name="MyFigure");
    panel = uipanel(f);
    vartnr = uisimvartuner(panel);

    Specify a list of variables to display in the variable tuner UI component using the VariablesFilter property.

    vartnr.VariablesFilter = {'x', 'y', 'z'}

    Input Arguments

    collapse all

    Parent container, specified as a Figure object created using the uifigure function or one of its child containers, such as a Tab, Panel, or GridLayout object. If you do not specify a parent container, MATLAB calls the uifigure function to create a new Figure object that serves as the parent container.

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: uisimvartuner(VariablesFilter={'x','y','z'})

    Note

    This section lists a subset of the available properties. For the full list, see VariableTuner Properties.

    Filter to display variables in the variable tuner UI component, specified as a cell array.

    Example: uisimvartuner(VariablesFilter={'x','y','z'})

    State of live variable tuning, specified as "on" or "off", or as logical true (1) or false (0). A value of "on" is equivalent to true, and "off" is equivalent to false. The property value has the type matlab.lang.OnOffSwitchState.

    • "on", true, or 1 — The UI component can tune variables during simulation.

    • "off", false, or 0 — The UI component can tune variables only between simulations and cannot tune variables during simulation.

    Simulation in which to tune variables, specified as a Simulation object.

    Tips

    • The simulation variable tuner UI component supports tuning variables that have these data types:

      • single

      • double

      • uint8, uint16, uint32, uint64

      • int8, int16, int32, int64

      • logical

      • matlab.lang.OnOffSwitchState

      • string

      • char

      • struct

    • Values specified using the simulation variable tuner UI component must be scalars or arrays.

    Version History

    Introduced in R2024a