Tuesday, July 23, 2024
HomeMatlabLeveraging The Simulink Diagnostics Viewer » Man on Simulink

Leveraging The Simulink Diagnostics Viewer » Man on Simulink

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.

However, many customers have to run a number of simulations in a single day utilizing the sim command, storing the outcomes to MAT-files for future evaluation. When doing so, there isn’t any Diagnostics Viewer robotically popping as much as inform you {that a} simulation triggered warnings. This doesn’t imply that try to be ignoring these, even when a warning doesn’t cease a simulation, that is typically signal of an precise downside that must be addressed.
On this weblog publish, I’ll illustrate the best way to overview warnings from a simulation executed by the sim command, each programmatically and interactively utilizing the Diagnostics Viewer.

Accessing Diagnostics Programmatically

In case you weren’t conscious, all diagnostics are saved within the Simulink.SimulationOutput object, as a part of the simulation metadata. Right here is an instance of the best way to entry this diagnostic data. First, let’s load a SimulationOutput object from a MAT-file:

information = load(‘mySavedData.mat’)

and verify if it accommodates any warnings:


On this case, we will see that it accommodates 4 warnings. We will have a look at the primary warning with this line:


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

To assist with that, just a few releases in the past (in R2020b) we added a operate to show all of the diagnostics saved in a SimulationOutput object within the Simulink Diagnostics Viewer, precisely like in the event you had clicked play within the canvas: sldiagviewer.reportSimulationMetadataDiagnostics.

If the mannequin is closed, the Diagnostics Viewer will launch standalone:


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:



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

I like to recommend going by the Diagnostics part of the documentation for more information on this subject.

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.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments