Simulink.ScenarioLog
View scenario simulation outcomes at any time step
Since R2022a
Description
A Simulink.ScenarioLog
object stores scenario simulation
outcomes at all time steps of a simulation. Use a Simulink.ScenarioLog
object to:
View actor information, such as runtime attributes and actions, at any time step.
View simulation information at any time step.
View diagnostics reported during simulation.
View values of user-defined action or event parameters at any time step.
Creation
Retrieve the Simulink.ScenarioLog
object that represents a simulation
log by using the get
function of a
Simulink.ScenarioSimulation
object. You can get the log of a simulation only if it
has logging enabled using the set
function of
the Simulink.ScenarioSimulation
object. You can get the log of a simulation
only after it stops playing.
Object Functions
get | Get logged scenario simulation data |
Examples
Get Simulation Log
Create Sim
, a Simulink.ScenarioSimulation
object.
rrApp = roadrunner('C:\RoadRunnerProject'); openScenario(rrApp,'TrajectoryCutIn'); Sim = createSimulation(rrApp);
Enable logging for the simulation.
set(Sim,'Logging','On');
Start the simulation.
set(Sim,'SimulationCommand', 'Start');
Get the simulation log after the simulation stops playing.
simLog = get(Sim, 'SimulationLog');
Get Actor Pose at First and Last Time Step
Get IDs of all actors from the simulation log.
actorIDs = get(simLog, 'ActorIDs')
actorIDs = 1 2 3
Get pose of actor with ID 1 at all time steps of the simulation run.
poseActor1 = get(simLog,'Pose','ActorID',1)
poseActor1 = 1×887 struct array with fields: Time Pose
Get pose of Actor ID 1 at first time step of the simulation run.
poseActor1FirstTimeStep = poseActor1(1)
poseActor1FirstTimeStep = struct with fields: Time: 0 Pose: [4×4 double]
poseActor1FirstTimeStep.Pose
ans = 0.9515 0.3077 -0.0008 7.8466 -0.3077 0.9515 -0.0026 -133.5547 0 0.0027 1.0000 -5.5290 0 0 0 1.0000
Get pose of actor with ID 1 at the last time step of the simulation run.
poseActor1LastTimeStep = poseActor1(887)
poseActor1LastTimeStep = struct with fields: Time: 17.7200 Pose: [4×4 double]
poseActor1LastTimeStep.Pose
ans = 0.9515 0.3077 -0.0008 7.8466 -0.3077 0.9515 -0.0026 167.9377 0 0.0027 1.0000 -5.5290 0 0 0 1.0000
Version History
Introduced in R2022a