Main Content

Simulink.SuppressedDiagnostic Class

Namespace: Simulink

Suppress diagnostic messages from a specified block


A Simulink.SuppressedDiagnostic object contains information related to diagnostic warnings or errors that are suppressed from being thrown during simulation.


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 justification for the suppressed diagnostic or restore the diagnostic by clicking Restore.

Diagnostic Viewer showing a suppressed diagnostic with buttons to add a comment or restore.

DiagnosticObject = Simulink.SuppressedDiagnostic(source, message_id) creates a suppressed diagnostic object. The object suppresses all instances of diagnostics represented by message_id thrown by the blocks specified by source.

Input Arguments

expand all

The source of the diagnostic, specified as a model, subsystem, block path, block handle, cell array of block paths, or cell array of block handles.

To get the block path, use the gcb function.

To get the block handle, use the getSimulinkBlockHandle function.

Data Types: char | cell | string

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 lastwarn function.

Data Types: char | string


expand all

Comments associated with the suppression object, specified as a character vector. This property is optional.

Data Types: char

The message identifier of the diagnostic that was suppressed, specified as a character vector.

Data Types: char

Date and time the suppression object was last modified, specified as a character vector. This property is read-only.

Data Types: char

Name of the user who last added or edited the suppression object, specified as a character vector. This property is optional.

Data Types: char

The block path of the model object that has a suppressed diagnostic, specified as a character vector.

Data Types: char


restoreRemove specified diagnostic suppressions
suppressSuppress diagnostic specified by Simulink.SuppressedDiagnostic object

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.


collapse all

To create and then restore a diagnostic suppression, use getDiagnosticObjects.m, 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';
  out = sim(model);

Create a Simulink.SuppressedDiagnostic object, suppression to suppress the parameter precision loss warning thrown by the Constant block, one.

  suppression = Simulink.SuppressedDiagnostic('Suppressor_CLI_Demo/one',...

The parameter precision loss warning is no longer thrown in future simulations of this model. Add accountability information to the object by editing the LastModifiedBy and Comments properties of the object.

  suppression.LastModifiedBy = 'John Doe';
  suppression.Comments = 'Reviewed: Joe Schmoe'

You can restore the diagnostic using the restore method.


Version History

Introduced in R2016b