Main Content

Simulink.restoreDiagnostic

Restore diagnostic warnings to a specific block, subsystem, or model

Description

example

Simulink.restoreDiagnostic(source) restores all suppressed diagnostics associated with the blocks specified by source.

example

Simulink.restoreDiagnostic(source, message_id) restores all instances of message_id on the blocks specified by source.

Simulink.restoreDiagnostic(diagnostic) restores the suppressed diagnostics associated with MSLDiagnostic object diagnostic.

example

Simulink.restoreDiagnostic(system, 'FindAll', 'on') restores all suppressed diagnostics associated with the system specified by system.

Examples

collapse all

To restore all suppressed diagnostics on a specified 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.

Create a cell array of message identifiers. Use the Simulink.suppressDiagnostic function to suppress these multiple diagnostics from the Constant block, one.

  diags = {'SimulinkFixedPoint:util:fxpParameterPrecisionLoss',...
   'SimulinkFixedPoint:util:fxpParameterUnderflow'};
  Simulink.suppressDiagnostic('Suppressor_CLI_Demo/one', diags);

Remove all suppressions and restore diagnostics to the block.

  Simulink.restoreDiagnostic('Suppressor_CLI_Demo/one');

To restore a suppressed diagnostic on a specified 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');

Remove the suppression and restore diagnostics to the block.

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

To restore all suppressed diagnostics on a specified subsystem, 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);

To restore all diagnostics from a system, use 'FindAll', 'on' to search within the system hierarchy. Specify the system or system handle within which to search.

  Simulink.restoreDiagnostic('Suppressor_CLI_Demo/Convert',...
   'FindAll', 'On');

To restore all suppressed diagnostics on a specified model, 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);

To restore all diagnostics from a model, specify the model name or model handle.

  Simulink.restoreDiagnostic('Suppressor_CLI_Demo','FindAll','on');

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 warnings and errors 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

The subsystem name, subsystem handle, model name, or model handle specified as a character vector.

Data Types: char

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

Data Types: struct

Version History

Introduced in R2016b