Main Content

sldiagviewer.reportSimulationMetadataDiagnostics

Display errors and warnings in Simulink.SimulationOutput object using Diagnostic Viewer

Description

example

sldiagviewer.reportSimulationMetadataDiagnostics(simOut) displays errors and warnings saved in the Simulink.SimulationOutput object simOut using the Diagnostic Viewer.

Examples

collapse all

You can use the sldiagviewer.reportSimulationMetadataDiagnostics function to display error and warning messages captured in a Simulink.SimulationOutput object using the Diagnostic Viewer.

Open the model ex_sldemo_bounce.

model = "ex_sldemo_bounce";
open_system(model)

Introduce an error into the model by specifying the Value parameter for the block Initial Velocity as the undefined variable z.

set_param("ex_sldemo_bounce/Initial Velocity","Value","z");

Create a Simulink.SimulationInput object to configure the simulation.

simIn = Simulink.SimulationInput(model);

Simulate the model. When you specify the StopOnError option as off, errors and warnings that occur during simulation are captured in the SimulationOutput object are not reported in the Command Window or script and do not interrupt the process of the script.

simOut = sim(simIn,"StopOnError","off","ShowProgress","off");
Warning: One or more simulations completed with errors. For more information, inspect the SimulationOutput objects at these indices: 
[1]

Use the sldiagviewer.reportSimulationMetadataDiagnostics function to display the warning and error messages from the simulation in the Diagnostic Viewer.

sldiagviewer.reportSimulationMetadataDiagnostics(simOut)

Input Arguments

collapse all

Simulation output that contains errors and warnings, specified as a Simulink.SimulationOutput object.

Version History

Introduced in R2020b