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
creates a DiagnosticObject
= Simulink.SuppressedDiagnostic(messageSource
,messageId
)SuppressedDiagnostic
object that suppresses all instances of
diagnostic messages represented by messageId
thrown by the block
specified by messageSource
.
Input Arguments
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
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
Examples
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 '<a href="matlab:open_and_hilite_hyperlink ('Suppressor_CLI_Demo/one','error')">Suppressor_CLI_Demo/one</a>'. 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. - <a href="matlab:Simulink.output.ParamDiagnosticFixits.fix('HighlightParam','Suppressor_CLI_Demo/one','ParameterPrecisionLossMsg');">Open</a> • To review details in the Parameter Quantization Advisor app, click the Open button. - <a href="matlab:Simulink.output.ParamDiagnosticFixits.fix('OpenParamQuantizeManager','Value','Suppressor_CLI_Demo/one');">Open</a> • - <a href="matlab:Simulink.SuppressedDiagnostic({'Suppressor_CLI_Demo/one'},'SimulinkFixedPoint:util:fxpParameterPrecisionLoss');">Suppress</a>
Warning: Parameter underflow occurred for 'Value' of '<a href="matlab:open_and_hilite_hyperlink ('Suppressor_CLI_Demo/one','error')">Suppressor_CLI_Demo/one</a>'. 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: • To review details in the Parameter Quantization Advisor app, click the Open button. - <a href="matlab:Simulink.output.ParamDiagnosticFixits.fix('OpenParamQuantizeManager','Value','Suppressor_CLI_Demo/one');">Open</a> • - <a href="matlab:Simulink.SuppressedDiagnostic({'Suppressor_CLI_Demo/one'},'SimulinkFixedPoint:util:fxpParameterUnderflow');">Suppress</a>
Warning: Saturate on overflow detected. This originated from '<a href="matlab:open_and_hilite_hyperlink ('Suppressor_CLI_Demo/Convert/FixPt To FixPt1','error')">Suppressor_CLI_Demo/Convert/FixPt To FixPt1</a>' Suggested Actions: • - <a href="matlab:Simulink.SuppressedDiagnostic({'Suppressor_CLI_Demo/Convert/FixPt To FixPt1'},'SimulinkFixedPoint:util:Saturationoccurred');">Suppress</a>
Warning: Saturate on overflow detected. This originated from '<a href="matlab:open_and_hilite_hyperlink ('Suppressor_CLI_Demo/Convert/FixPt To FixPt2','error')">Suppressor_CLI_Demo/Convert/FixPt To FixPt2</a>' Suggested Actions: • - <a href="matlab:Simulink.SuppressedDiagnostic({'Suppressor_CLI_Demo/Convert/FixPt To FixPt2'},'SimulinkFixedPoint:util:Saturationoccurred');">Suppress</a>
Warning: Saturate on overflow detected. This originated from '<a href="matlab:open_and_hilite_hyperlink ('Suppressor_CLI_Demo/Convert/FixPt To FixPt3','error')">Suppressor_CLI_Demo/Convert/FixPt To FixPt3</a>' Suggested Actions: • - <a href="matlab:Simulink.SuppressedDiagnostic({'Suppressor_CLI_Demo/Convert/FixPt To FixPt3'},'SimulinkFixedPoint:util:Saturationoccurred');">Suppress</a>
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: [0×1 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: '2025-Feb-01 17:09:00'
Simulate the model.
out2 = sim(model);
Warning: Parameter underflow occurred for 'Value' of '<a href="matlab:open_and_hilite_hyperlink ('Suppressor_CLI_Demo/one','error')">Suppressor_CLI_Demo/one</a>'. 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: • To review details in the Parameter Quantization Advisor app, click the Open button. - <a href="matlab:Simulink.output.ParamDiagnosticFixits.fix('OpenParamQuantizeManager','Value','Suppressor_CLI_Demo/one');">Open</a> • - <a href="matlab:Simulink.SuppressedDiagnostic({'Suppressor_CLI_Demo/one'},'SimulinkFixedPoint:util:fxpParameterUnderflow');">Suppress</a>
Warning: Saturate on overflow detected. This originated from '<a href="matlab:open_and_hilite_hyperlink ('Suppressor_CLI_Demo/Convert/FixPt To FixPt1','error')">Suppressor_CLI_Demo/Convert/FixPt To FixPt1</a>' Suggested Actions: • - <a href="matlab:Simulink.SuppressedDiagnostic({'Suppressor_CLI_Demo/Convert/FixPt To FixPt1'},'SimulinkFixedPoint:util:Saturationoccurred');">Suppress</a>
Warning: Saturate on overflow detected. This originated from '<a href="matlab:open_and_hilite_hyperlink ('Suppressor_CLI_Demo/Convert/FixPt To FixPt2','error')">Suppressor_CLI_Demo/Convert/FixPt To FixPt2</a>' Suggested Actions: • - <a href="matlab:Simulink.SuppressedDiagnostic({'Suppressor_CLI_Demo/Convert/FixPt To FixPt2'},'SimulinkFixedPoint:util:Saturationoccurred');">Suppress</a>
Warning: Saturate on overflow detected. This originated from '<a href="matlab:open_and_hilite_hyperlink ('Suppressor_CLI_Demo/Convert/FixPt To FixPt3','error')">Suppressor_CLI_Demo/Convert/FixPt To FixPt3</a>' Suggested Actions: • - <a href="matlab:Simulink.SuppressedDiagnostic({'Suppressor_CLI_Demo/Convert/FixPt To FixPt3'},'SimulinkFixedPoint:util:Saturationoccurred');">Suppress</a>
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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)