Main Content

sldiagviewer.reportSimulationMetadataDiagnostics

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

Since R2020b

Description

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

example

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.

Create a Simulink.SimulationInput object to configure a simulation of the model ex_sldemo_bounce.

mdl = "ex_sldemo_bounce";
simin = Simulink.SimulationInput(mdl);

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

blk = mdl + "/Initial Velocity";
simin = setBlockParameter(simin,blk,"Value","z");

To prevent the error from interrupting the script execution, enable the CaptureErrors parameter on the SimulationInput object. When the CaptureErrors parameter is enabled, errors and warnings that occur during the simulation are captured in the SimulationOutput object and are not reported in the Command Window or script.

simin = setModelParameter(simin,CaptureErrors="on");

Simulate the model. To run the simulation, the sim function loads the model without opening the model in the Simulink Editor.

out = sim(simin);

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

sldiagviewer.reportSimulationMetadataDiagnostics(out)

Input Arguments

collapse all

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

Version History

Introduced in R2020b