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
messageSource
— System, block, or model throwing diagnostic message
string scalar | character vector
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
messageId
— Identifier of diagnostic message
string scalar | character vector
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
Source
— Path of block with suppressed diagnostic messages
character vector
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
Id
— Identifier of suppressed diagnostic message
character vector
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
Cause
— Underlying reasons for diagnostic message
character vector
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
LastModifiedBy
— Name of user who last added or edited suppression object
character vector
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
— Comments associated with suppression object
character vector
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
LastModified
— Date and time suppression object was last modified
character vector
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
Suppress and Restore Diagnostic Suppression Using Simulink.SuppressedDiagnostic Object
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-Sep-05 19:30:02'
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
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: .
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)