メインコンテンツ

Simulink.SuppressedDiagnostic クラス

名前空間: Simulink
スーパークラス: matlab.mixin.Heterogeneous

特定のブロックからの診断メッセージを非表示にする

説明

Simulink.SuppressedDiagnostic オブジェクトには、シミュレーション中に非表示にされている診断メッセージに関連する情報が含まれています。

Simulink.SuppressedDiagnostic クラスは handle クラスです。

クラス属性

ConstructOnLoad
true
HandleCompatible
true

クラス属性の詳細については、クラスの属性を参照してください。

作成

説明

DiagnosticObject = Simulink.SuppressedDiagnostic(messageSource,messageId)SuppressedDiagnostic オブジェクトを作成します。このオブジェクトは、messageSource で指定されたブロックがスローした、messageId で表される診断メッセージのすべてのインスタンスを非表示にします。

入力引数

すべて展開する

診断メッセージをスローするシステム、ブロック、またはモデルのパスあるいはハンドル。string スカラーまたは文字ベクトルとして指定します。

ブロック パスとブロック ハンドルを取得するには、それぞれ gcb 関数と getSimulinkBlockHandle 関数を使用します。

データ型: string | char

診断メッセージの識別子。string スカラーまたは文字ベクトルとして指定します。シミュレーションに関連付けられた Simulink.SimulationMetadata オブジェクトの ExecutionInfo プロパティにアクセスすることで、または lastwarn 関数を使用することで、シミュレーション中にスローされた診断メッセージの識別子を見つけることができます。

データ型: string | char

プロパティ

すべて展開する

診断メッセージが非表示にされたモデル内のブロックの相対パス。文字ベクトルとして指定します。

例: 'Suppressor_CLI_Demo/one'

属性:

GetAccess
public
SetAccess
アクセスを制限
Transient
true
NonCopyable
true

データ型: char

非表示にされた診断メッセージの識別子。文字ベクトルとして指定します。

例: 'SimulinkFixedPoint:util:fxpParameterPrecisionLoss'

属性:

GetAccess
public
SetAccess
アクセスを制限
Transient
true
NonCopyable
true

データ型: char

診断メッセージの根本的な理由。文字ベクトルとして指定します。

例: 'Attempt to divide by zero.'

属性:

GetAccess
public
SetAccess
アクセスを制限
Transient
true
NonCopyable
true

データ型: char

非表示オブジェクトを最後に追加または編集したユーザーの名前。文字ベクトルとして指定します。

例: 'User A'

属性:

GetAccess
public
SetAccess
public
Transient
true
NonCopyable
true

データ型: char

非表示オブジェクトに関連付けられたコメント。文字ベクトルとして指定します。

例: 'Reviewed by User B'

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

データ型: char

非表示オブジェクトが最後に変更された日付と時刻。文字ベクトルとして指定します。

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

属性:

GetAccess
public
SetAccess
アクセスを制限
NonCopyable
true

データ型: char

メソッド

すべて展開する

すべて折りたたむ

Simulink.SuppressedDiagnostic オブジェクトを作成して、Simulink® モデルの特定のブロックがスローする診断メッセージを非表示にし、オブジェクトの LastModifiedBy プロパティと Comments プロパティを設定して、アカウンタビリティの情報をオブジェクトに追加します。

モデル Suppressor_CLI_Demo を読み込みます。

model = "Suppressor_CLI_Demo";
load_system(model);

Simulink.SimulationMetadata クラスにアクセスするには、ReturnWorkspaceOutputs パラメーター値を 'on' に設定します。

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

モデルのシミュレーションを実行します。

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>

シミュレーション中にいくつかの警告が生成されます。シミュレーション中にスローされた診断メッセージの詳細を取得するには、getDiagnosticObjects.m を使用して、Simulink.SimulationMetadataオブジェクトの ExecutionInfo プロパティにアクセスします。

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

シミュレーション中にスローされた最初の警告の詳細を取得します。この警告は、Constant ブロック one によってスローされた、識別子 'SimulinkFixedPoint:util:fxpParameterPrecisionLoss' をもつパラメーターの桁落ちに関する警告です。

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]

SuppressedDiagnostic オブジェクトを作成し、この警告を非表示にします。

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

オブジェクトの LastModifiedBy プロパティと Comments プロパティを設定することで、アカウンタビリティの情報をオブジェクトに追加します。

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-Jul-18 13:09:11'

モデルのシミュレーションを実行します。

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>

パラメーターの桁落ちに関する警告が非表示になります。

診断を元に戻すには、restoreメソッドを使用します。

restore(suppression);

代替方法

診断ビューアーから、モデルの特定の診断メッセージを非表示にできます。診断メッセージを非表示にするには、診断ビューアーでメッセージの横にある [非表示にする] ボタンをクリックします。この操作で、Simulink.SuppressedDiagnostic オブジェクトが作成されます。MATLAB® コマンド ウィンドウでこのオブジェクトにアクセスするには、Simulink.getSuppressedDiagnostics 関数を使用します。詳細については、Suppress Diagnostic Messagesを参照してください。

バージョン履歴

R2016b で導入