execute
クラス: slmetric.Engine
名前空間: slmetric
(削除予定) メトリクス データを収集する
メトリクス ダッシュボード ユーザー インターフェイス、関数 metricdashboard
、slmetric
パッケージ API、および対応するカスタマイズは将来のリリースで削除される予定です。詳細については、Migrating from Metrics Dashboard to Model Maintainability Dashboardを参照してください。
説明
指定したメトリクス エンジン オブジェクトに対してモデル メトリクス データを収集します。モデル メトリクス データは、定義されているアーキテクチャ コンポーネントに基づきます。コンポーネントは以下の Simulink オブジェクトです。
モデル
Subsystem ブロック
チャート
MATLAB Function ブロック
保護モデル
execute(
は、使用可能なモデル メトリクスのメトリクス データを収集します。これには、MathWorks メトリクスおよびカスタム メトリクスが含まれる可能性があります。metric_engine
)
入力引数
metric_engine
— メトリクス エンジン オブジェクト
slmetric.Engine
オブジェクト
slmetric.Engine
オブジェクトを作成します。
metric_engine = slmetric.Engine();
MetricIDs
— メトリクス識別子
文字ベクトル | 文字ベクトルの cell 配列
モデル メトリクスまたは作成したカスタム モデル メトリクスのメトリクス識別子。1 つ以上のメトリクス識別子を指定できます。slmetric.metric.getAvailableMetrics
を呼び出してメトリクス識別子を取得できます。
例: 'mathworks.metrics.DescriptiveBlockNames'
例
モデルのメトリクス データの収集とアクセス
モデル sldemo_mdlref_basic
のモデル メトリクス データを収集してそのデータにアクセスします。
モデルを開きます。
openExample('sldemo_mdlref_basic');
slmetric.Engine
オブジェクトを作成し、解析用にモデル内のルートを設定します。
metric_engine = slmetric.Engine(); % Include referenced models and libraries in the analysis. % These properties are on by default. metric_engine.ModelReferencesSimulationMode = 'AllModes'; metric_engine.AnalyzeLibraries = 1; setAnalysisRoot(metric_engine, 'Root', 'sldemo_mdlref_basic');
モデル メトリクス データの収集
execute(metric_engine);
モデル メトリクス データを取得して、slmetric.metric.ResultCollection
オブジェクトの配列 res_col
を返します。
res_col = getMetrics(metric_engine, 'mathworks.metrics.SimulinkBlockCount');
mathworks.metrics.SimulinkBlockCount
メトリクスの結果を表示します。
for n=1:length(res_col) if res_col(n).Status == 0 result = res_col(n).Results; for m=1:length(result) disp(['MetricID: ',result(m).MetricID]); disp([' ComponentPath: ', result(m).ComponentPath]); disp([' Value: ', num2str(result(m).Value)]); disp([' AggregatedValue: ', num2str(result(m).AggregatedValue)]); end else disp(['No results for:', result(n).MetricID]); end disp(' '); end
1 つのメトリクスのメトリクス データの収集とアクセス
モデル sldemo_mdlref_basic
のモデル メトリクス データを収集してそのデータにアクセスします。
モデルを開きます。
openExample('sldemo_mdlref_basic');
slmetric.Engine
オブジェクトを作成します。参照モデルおよびライブラリを解析に含め、解析用にモデル内のルートを設定します。
metric_engine = slmetric.Engine(); metric_engine.ModelReferencesSimulationMode = 'AllModes'; metric_engine.AnalyzeLibraries = 1; setAnalysisRoot(metric_engine, 'Root', 'sldemo_mdlref_basic');
モデル メトリクス データの収集
execute(metric_engine, 'mathworks.metrics.ExplicitIOCount');
モデル メトリクス データを取得して、slmetric.metric.ResultCollection
オブジェクトの配列 res_col
を返します。
res_col = getMetrics(metric_engine, 'mathworks.metrics.ExplicitIOCount');
mathworks.metrics.ExplicitIOCount
メトリクスの結果を表示します。
for n=1:length(res_col) if res_col(n).Status == 0 result = res_col(n).Results; for m=1:length(result) disp(['MetricID: ',result(m).MetricID]); disp([' ComponentPath: ', result(m).ComponentPath]); disp([' Value: ', num2str(result(m).Value)]); disp([' AggregatedValue: ', num2str(result(m).AggregatedValue)]); disp([' Measures: ', num2str(result(m).Measures)]); disp([' AggregatedMeasures: ', num2str(result(m).AggregatedMeasures)]); end else disp(['No results for:', result(n).MetricID]); end disp(' '); end
結果は次のようになります。
MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_basic Value: 3 AggregatedValue: 4 Measures: 0 3 AggregatedMeasures: 3 3 MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_basic/More Info Value: 0 AggregatedValue: 0 Measures: 0 0 AggregatedMeasures: 0 0 MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_counter Value: 4 AggregatedValue: 4 Measures: 3 1 AggregatedMeasures: 3 1
ComponentPath: sldemo_mdlref_basic
では、出力が 3
つあるため、値は 3
です。3 つの出力は、配列 Measures
の 2 番目の要素に入ります。slmetric.metric.AggregationMode
が Max
であるため、AggregatedValue
は、sldemo_mdlref_counter
への入出力の数である 4
です。配列 AggregratedMeasures
には、コンポーネントまたはサブコンポーネントの入力および出力の最大数が含まれます。
バージョン履歴
R2016a で導入R2022a: メトリクス ダッシュボードは削除予定
メトリクス ダッシュボード ユーザー インターフェイス、関数 metricdashboard
、slmetric
パッケージ API、および対応するカスタマイズは将来のリリースで削除される予定です。詳細については、Migrating from Metrics Dashboard to Model Maintainability Dashboardを参照してください。
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
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)