メインコンテンツ

addObserver

Add observer to scenario simulation

Since R2022a

    Description

    An observer is a type of actor that you can create and add to the MATLAB® cosimulation client in addition to the main actors participating in a scenario. Observers can only read simulation states without modifying them in any way during simulation. The purpose of observers is to allow for custom computations, for example, visualization and runtime analysis of simulation data. For instance, an observer can notice if a vehicle is too close to another vehicle.

    observer = addObserver(ScenarioSim,ObserverName,FileName) adds an observer named ObserverName represented by a MATLAB System object™, or a Simulink® model in the file FileName, to the scenario simulation ScenarioSim. If the command is successful, then the function returns logical 1 (true). Otherwise, the function returns logical 0 (false).

    Input Arguments

    collapse all

    RoadRunner Scenario simulation, specified as a ScenarioSimulation object.

    Example: ScenarioSim

    Name of the observer, specified as a string or character vector. Choose a unique and meaningful name for the observer.

    Example: "RedCarObserver"

    Name of the System object file, or name of the Simulink file containing the observer code, or an observer model, respectively. Specified as a string or character vector.

    You may use a MATLAB System object or a Simulink model, depending on how you choose to implement the observer.

    To create and add an observer from MATLAB, see Simulate RoadRunner Scenarios with Observers Modeled in MATLAB or Simulink.

    Example: "mySysObserver.m"

    Example: "blueTruckObserver.slx"

    Version History

    Introduced in R2022a

    expand all