Suppress diagnostic messages from a specified block
Simulink.SuppressedDiagnostic object contains information related to
diagnostic warnings or errors that are suppressed from being thrown during
The Diagnostic Viewer in Simulink® includes an option to suppress certain diagnostics. This feature enables
you to suppress warnings or errors for specific objects in your model. Click the
Suppress button next to the warning in the Diagnostic Viewer
to suppress the warning from the specified source. This action creates a
Simulink.SuppressedDiagnostic object. You can access this object
at the MATLAB® command line using the
Simulink.getSuppressedDiagnostics function. You can add a comment for
the suppressed diagnostic. You can restore the diagnostic by clicking
creates a suppressed diagnostic object. The object suppresses all instances of
diagnostics represented by
DiagnosticObject = Simulink.SuppressedDiagnostic(
message_id thrown by the blocks specified
source — System, block, or model object throwing diagnostic
model | subsystem | block path | block handle
message_id — message identifier of diagnostic
The message identifier of the diagnostic, specified as a character
vector or string. You can find the message identifier of diagnostics
thrown during simulation by accessing the
ExecutionInfo property of the
Simulink.SimulationMetadata object associated with a
simulation. You can also use the
Comments — Comments associated with the suppression object
Comments associated with the suppression object, specified as a character vector. This property is optional.
ID — Message identifier of the diagnostic that was suppressed
The message identifier of the diagnostic that was suppressed, specified as a character vector.
LastModified — Date and time the suppression object was last modified
Date and time the suppression object was last modified, specified as a character vector. This property is read-only.
LastModifiedBy — Name of the user who was last to add or edit the suppression object
Name of the user who last added or edited the suppression object, specified as a character vector. This property is optional.
Source — block path of the source of the diagnostic
The block path of the model object that has a suppressed diagnostic, specified as a character vector.
|Remove specified diagnostic suppressions
|Suppress diagnostic specified by
Handle. To learn how handle classes affect copy operations, see Copying Objects.
Create a Simulink.SuppressedDiagnostic Object
To create and then restore a diagnostic suppression, use
suppressor_script.m, and the
Suppressor_CLI_Demo.slx model. The
getDiagnosticObjects.m function queries the simulation metadata to access diagnostics that were thrown during simulation. The
suppressor_script.m script contains the commands for suppressing and restoring diagnostics to the
Suppressor_CLI_Demo model. Open the model. To access
Simulink.SimulationMetadata class, set the
ReturnWorkspaceOutputs parameter value to
'on'. Simulate the model.
model = 'Suppressor_CLI_Demo'; open_system(model); set_param(model,'ReturnWorkspaceOutputs','on'); out = sim(model);
Simulink.SuppressedDiagnostic object, suppression to suppress the parameter precision loss warning thrown by the Constant block,
suppression = Simulink.SuppressedDiagnostic('Suppressor_CLI_Demo/one',... 'SimulinkFixedPoint:util:fxpParameterPrecisionLoss');
The parameter precision loss warning is no longer thrown in future simulations of this model. Add accountability information to the object by editing the
Comments properties of the object.
suppression.LastModifiedBy = 'John Doe'; suppression.Comments = 'Reviewed: Joe Schmoe'
You can restore the diagnostic using the restore method.
Introduced in R2016b