Main Content

uisimcontrols

R2026b

Create simulation controls UI component in app

Since R2024a

    Description

    simctrl = uisimcontrols creates simulation controls in a new figure and returns the SimulationControls object. MATLAB® calls the uifigure function to create the figure. The simulation controls include a run button and a stop button. The run button has three states:

    • Run — The simulation is inactive or initialized. Clicking the button starts the simulation.

    • Pause — The simulation is running. Clicking the button pauses the simulation.

    • Continue — The simulation is paused. Clicking the button resumes the simulation.

    simctrl = uisimcontrols(p) creates simulation controls in the specified parent container. The parent can be a Figure object or one of its child containers.

    simctrl = uisimcontrols(___,Name=Value) creates simulation controls with properties specified by one or more name-value arguments.

    example

    Examples

    collapse all

    Add a simulation controls component to an app. Then, connect the component to a Simulation object.

    Create simulation controls inside a panel in a UI figure.

    f = uifigure(Name="MyFigure");
    panel = uipanel(f);
    simctrl = uisimcontrols(panel);

    To connect the simulation controls to a simulation, specify the Simulation property.

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

    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: uisimcontrols(StartText="Start Sim")

    Note

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

    Start state label, specified as one of these options:

    • A string or a character vector — Specify a single line of text for the label.

    • A string array or a cell array of character vectors — Specify multiple lines of text for the label.

    • A 1-D categorical array — Specify one or more lines of text for the label. The label uses the values in the array, not the categories.

    Example: uisimcontrols(StartText="Start Sim")

    Pause state label, specified as one of these options:

    • A string or a character vector — Specify a single line of text for the label.

    • A string array or a cell array of character vectors — Specify multiple lines of text for the label.

    • A 1-D categorical array — Specify one or more lines of text for the label. The label uses the values in the array, not the categories.

    Example: uisimcontrols(PauseText="Pause Sim")

    Continue state label, specified as one of these options:

    • A string or a character vector — Specify a single line of text for the label.

    • A string array or a cell array of character vectors — Specify multiple lines of text for the label.

    • A 1-D categorical array — Specify one or more lines of text for the label. The label uses the values in the array, not the categories.

    Example: uisimcontrols(ContinueText="Resume")

    Stop state label, specified as one of these options:

    • A string or a character vector — Specify a single line of text for the label.

    • A string array or a cell array of character vectors — Specify multiple lines of text for the label.

    • A 1-D categorical array — Specify one or more lines of text for the label. The label uses the values in the array, not the categories.

    Example: uisimcontrols(StopText="Stop Sim")

    Simulation to control, specified as a Simulation object.

    Version History

    Introduced in R2024a