Main Content

Simulink.SuppressedDiagnostic Class

Namespace: Simulink
Superclasses: matlab.mixin.Heterogeneous

Suppress diagnostic messages from specific block

Description

A Simulink.SuppressedDiagnostic object contains information related to diagnostic messages that are suppressed during simulation.

The Simulink.SuppressedDiagnostic class is a handle class.

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

DiagnosticObject = Simulink.SuppressedDiagnostic(messageSource,messageId) creates a SuppressedDiagnostic object that suppresses all instances of diagnostic messages represented by messageId thrown by the block specified by messageSource.

example

Input Arguments

expand all

System, block, or model path or handle that throws the diagnostic message, specified as a string scalar or character vector.

To get block path and block handle, use the gcb and getSimulinkBlockHandle functions, respectively.

Data Types: string | char

Identifier of the diagnostic message, specified as a string scalar or character vector. You can find the identifier of diagnostics messages thrown during simulation by accessing the ExecutionInfo property of the Simulink.SimulationMetadata object associated with a simulation or by using the lastwarn function.

Data Types: string | char

Properties

expand all

Relative path of the block in the model that has the suppressed diagnostic messages, specified as a character vector.

Example: 'Suppressor_CLI_Demo/one'

Attributes:

GetAccess
public
SetAccess
Restricts access
Transient
true
NonCopyable
true

Data Types: char

Identifier of the suppressed diagnostic message, specified as a character vector.

Example: 'SimulinkFixedPoint:util:fxpParameterPrecisionLoss'

Attributes:

GetAccess
public
SetAccess
Restricts access
Transient
true
NonCopyable
true

Data Types: char

Underlying reasons for the diagnostic message, specified as a character vector.

Example: 'Attempt to divide by zero.'

Attributes:

GetAccess
public
SetAccess
Restricts access
Transient
true
NonCopyable
true

Data Types: char

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

Example: 'User A'

Attributes:

GetAccess
public
SetAccess
public
Transient
true
NonCopyable
true

Data Types: char

Comments associated with the suppression object, specified as a character vector.

Example: 'Reviewed by User B'

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char

Date and time the suppression object was last modified, specified as a character vector.

Example: '2024-May-17 12:57:29'

Attributes:

GetAccess
public
SetAccess
Restricts access
NonCopyable
true

Data Types: char

Methods

expand all

Examples

collapse all

Create a Simulink.SuppressedDiagnostic object to suppress diagnostic messages thrown by a specific block of a Simulink® model and add accountability information to the object by setting its LastModifiedBy and Comments properties.

Load the model Suppressor_CLI_Demo.

model = "Suppressor_CLI_Demo";
load_system(model);

To access Simulink.SimulationMetadata class, set the ReturnWorkspaceOutputs parameter value to 'on'.

set_param(model,'ReturnWorkspaceOutputs','on');

Simulate the model.

out1 = sim(model);
Warning: Parameter precision loss occurred for 'Value' of 'Suppressor_CLI_Demo/one'.  The original value of the parameter, 0.01, cannot be represented exactly using the run-time data type sfix16_En5. The value is quantized to 0. Quantization error occurred with an absolute difference of 0.01 and a relative difference of 1. 
Suggested Actions:
    • To control the level of precision loss at which a warning or error is issued, adjust the diagnostic threshold settings. - Open
    • Inspect details in the Parameter Quantization Advisor. - Open
    •  - Suppress

Warning: Parameter underflow occurred for 'Value' of 'Suppressor_CLI_Demo/one'.  The value of the parameter, 0.01, is non-zero, but after quantization to the run-time data type sfix16_En5, the value is zero (0). Quantization error occurred with an absolute difference of 0.01 and a relative difference of 1. 
Suggested Actions:
    • Inspect details in the Parameter Quantization Advisor. - Open
    •  - Suppress

Warning: Saturate on overflow detected. This originated from 'Suppressor_CLI_Demo/Convert/FixPt To FixPt1'
Suggested Actions:
    •  - Suppress

Warning: Saturate on overflow detected. This originated from 'Suppressor_CLI_Demo/Convert/FixPt To FixPt2'
Suggested Actions:
    •  - Suppress

Warning: Saturate on overflow detected. This originated from 'Suppressor_CLI_Demo/Convert/FixPt To FixPt3'
Suggested Actions:
    •  - Suppress

Several warnings are generated during simulation. To get details of the diagnostic messages that were thrown during simulation, access the ExecutionInfo property of the Simulink.SimulationMetadata object by using getDiagnosticObjects.m.

if(exist('out1', 'var'))
  diag_objects = getDiagnosticObjects(out1);
end

Get details of the first warning thrown during simulation. The warning is a parameter precision loss warning with identifier 'SimulinkFixedPoint:util:fxpParameterPrecisionLoss' thrown by the Constant block one.

warning = diag_objects(1)
warning = 
  MSLDiagnostic with properties:

    identifier: 'SimulinkFixedPoint:util:fxpParameterPrecisionLoss'
       message: 'Parameter precision loss occurred for 'Value' of 'Suppressor_CLI_Demo/one'.  The original value of the parameter, 0.01, cannot be represented exactly using the run-time data type sfix16_En5. The value is quantized to 0. Quantization error occurred with an absolute difference of 0.01 and a relative difference of 1. '
         paths: {'Suppressor_CLI_Demo/one'}
         cause: {}
         stack: [0x1 struct]

Create a SuppressedDiagnostic object and suppress this warning.

suppression =...
 Simulink.SuppressedDiagnostic(warning.paths,warning.identifier);

Add accountability information to the object by setting its LastModifiedBy and Comments properties.

suppression.LastModifiedBy = 'User A';
suppression.Comments = 'Reviewed by User B';
suppression
suppression = 
  SuppressedDiagnostic with properties:

            Source: 'Suppressor_CLI_Demo/one'
                Id: 'SimulinkFixedPoint:util:fxpParameterPrecisionLoss'
             Cause: ''
    LastModifiedBy: 'User A'
          Comments: 'Reviewed by User B'
      LastModified: '2024-Jul-20 19:21:49'

Simulate the model.

out2 = sim(model);
Warning: Parameter underflow occurred for 'Value' of 'Suppressor_CLI_Demo/one'.  The value of the parameter, 0.01, is non-zero, but after quantization to the run-time data type sfix16_En5, the value is zero (0). Quantization error occurred with an absolute difference of 0.01 and a relative difference of 1. 
Suggested Actions:
    • Inspect details in the Parameter Quantization Advisor. - Open
    •  - Suppress

Warning: Saturate on overflow detected. This originated from 'Suppressor_CLI_Demo/Convert/FixPt To FixPt1'
Suggested Actions:
    •  - Suppress

Warning: Saturate on overflow detected. This originated from 'Suppressor_CLI_Demo/Convert/FixPt To FixPt2'
Suggested Actions:
    •  - Suppress

Warning: Saturate on overflow detected. This originated from 'Suppressor_CLI_Demo/Convert/FixPt To FixPt3'
Suggested Actions:
    •  - Suppress

The parameter precision loss warning is suppressed.

To restore the diagnostic, use the restore method.

restore(suppression);

Alternatives

You can suppress certain diagnostic messages in your model from the Diagnostic Viewer. To suppress a diagnostic message, click the Suppress button next to the message in the Diagnostic Viewer. This action creates a Simulink.SuppressedDiagnostic object. To access this object in the MATLAB® Command window, use the Simulink.getSuppressedDiagnostics function. For more information, see Suppress Diagnostic Messages.

Version History

Introduced in R2016b