Main Content

Simulink.suppressDiagnostic

Suppress a diagnostic from a specific block

Description

example

Simulink.suppressDiagnostic(source, message_id) suppresses all instances of diagnostics represented by message_id thrown by the blocks specified by source.

Simulink.suppressDiagnostic(diagnostic) suppresses the diagnostics associated with MSLDiagnostic object diagnostic.

Examples

collapse all

To suppress a warning thrown by a block, 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';
  open_system(model);
  set_param(model,'ReturnWorkspaceOutputs','on');
  out = sim(model);

Use the Simulink.suppressDiagnostic function to suppress the parameter precision loss warning thrown by the Constant block, one.

  Simulink.suppressDiagnostic('Suppressor_CLI_Demo/one',...
     'SimulinkFixedPoint:util:fxpParameterPrecisionLoss');

Input Arguments

collapse all

The source of the diagnostic, specified as a 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

Message identifier of the diagnostic, specified as a character vector or a cell array of character vectors. 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 | cell

Diagnostic specified as an MSLDiagnostic object. Access the MSLDiagnostic object through the ExecutionInfo property of the Simulink.SimulationMetadata object.

Data Types: struct