I’m certain most Simulink customers will agree that viewing and analyzing warnings and errors is a vital a part of working with Simulink fashions. When simulating fashions interactively utilizing the play button, all diagnostics are simply noticeable since they seem within the Diagnostics Viewer as they happen.
Accessing Diagnostics Programmatically
information = load(‘mySavedData.mat’)
and verify if it accommodates any warnings:
information.out.SimulationMetadata.ExecutionInfo.WarningDiagnostics
On this case, we will see that it accommodates 4 warnings. We will have a look at the primary warning with this line:
information.out.SimulationMetadata.ExecutionInfo.WarningDiagnostics(1).Diagnostic
Whereas this API provides entry to all of the wanted data and permits you to construct tooling round it, it may be tedious to kind all that to see every warning one after the other.
Visualizing Diagnostics within the Diagnostics Viewer
If the mannequin is closed, the Diagnostics Viewer will launch standalone:
sldiagviewer.reportSimulationMetadataDiagnostics(information.out);
If the mannequin is opened, the Diagnostics Viewer will open docked within the mannequin, as in the event you had simulated the mannequin utilizing the play button from the toolstrip:
open_system(information.out.SimulationMetadata.ModelInfo.ModelName);
sldiagviewer.reportSimulationMetadataDiagnostics(information.out);
Extra on the Simulink Diagnostics Viewer
If you’re utilizing the newest model of MATLAB (R2021b), you could have seen that the Diagnostics Viewer is now docked within the Simulink canvas by default. For those who favor to maintain it undocked, there may be an possibility that controls this within the Simulink preferences, or below Diagnostics within the Debug tab:
Additionally, in case you had not seen, like most panels within the Simulink canvas, the docked Diagnostics Viewer may be moved to the highest, backside, left or proper aspect of the canvas. For instance, I typically favor seeing it on the precise:
Now it is your flip
Within the feedback under, I might be curious to listen to in the event you favor the Diagnostics Viewer docked or undocked, and if docked, the place within the canvas you favor it.