Main Content

Simulink.ScenarioSimulation

Create, access, and control scenario simulation

    Description

    A Simulink.ScenarioSimulation object is the representation of a RoadRunner Scenario simulation in MATLAB®. Use a Simulink.ScenarioSimulation object to perform these actions:

    • Control a simulation: start, pause, resume, stop, or move the simulation a single step forward.

    • Access and modify the runtime parameters of a simulation.

    • Report custom diagnostic messages during a simulation.

    Creation

    You can create a Simulink.ScenarioSimulation object using the createSimulation function.

    Object Functions

    addObserverAdd observer to scenario simulation
    getGet value of scenario simulation parameter
    removeObserverRemove observer from scenario simulation
    reportDiagnostic Report information, warning or error message during scenario simulation
    setSet value of scenario simulation parameter
    Simulink.ScenarioSimulation.findReturn scenario simulations or actors in current MATLAB session

    Examples

    Create Simulation

    Create a RoadRunner Scenario object and open a scenario file.

    rrApp = roadrunner('C:\Project\TestRoute');
    openScenario(rrApp,'TrajectoryCutIn');

    Create the corresponding Simulink.ScenarioSimulation object and start the simulation.

    scenario = createSimulation(rrApp);
    set(scenario, 'SimulationCommand', 'Start'); 
    

    Version History

    Introduced in R2022a