Main Content


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

Since R2020b



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


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";

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");

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


Input Arguments

collapse all

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

Version History

Introduced in R2020b