Simulink Collect Metricsのロゴ

Simulink Collect Metrics

組織人気
matlab
simulink-collect-metrics

Collect and assess quality metrics for Simulink models using the metric.Engine API. Use when evaluating model design quality (maintainability, complexity, architecture) or testing completeness (unit testing, SIL, PIL, coverage, pass rates) after edits or test runs. Covers metric discovery, collection, report generation, and diagnostics. Triggers on: "collect metrics", "quality metrics", "metric.Engine", "testing metrics", "maintainability metrics", "SIL metrics", "PIL metrics", "what metrics are available", "assess quality", "coverage metrics", "generate metric report", "diagnose metric errors".

概要

公開者matlab
リポジトリsimulink-agentic-toolkit
スキル名simulink-collect-metrics
スター
1.2K
フォーク
112
同梱ファイル
5
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 5個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    matlabがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Simulink Collect Metrics」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/matlab/simulink-agentic-toolkit/tree/main/skills-catalog/verification-validation-and-test/simulink-collect-metrics
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/matlab/simulink-agentic-toolkit.git /tmp/simulink-agentic-toolkit
mkdir -p .claude/skills
cp -r /tmp/simulink-agentic-toolkit/skills-catalog/verification-validation-and-test/simulink-collect-metrics .claude/skills/simulink-collect-metrics
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでSimulink Collect Metricsを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にSimulink Collect Metricsを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Simulink Collect Metricsは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Collect Quality Metrics

Assess the quality and completeness of model edits and testing work using metric.Engine. This skill teaches the canonical workflow for discovering, collecting, and interpreting quality metrics across releases.

When to Use

  • After editing a model — assess maintainability, complexity, or design quality
  • After running tests — assess coverage, pass rates, requirements traceability
  • When asked to collect or check quality metrics from a MATLAB project
  • When diagnosing why metrics show errors or missing data
  • When generating metric reports (HTML, PDF)
  • When asked what metrics are available for a project

When NOT to Use

  • No MATLAB project is open — metric.Engine requires an open project
  • Writing or running tests — use matlab-testing
  • Static code analysis or coding standards — use matlab-review-code
  • Model Advisor compliance checks — use checking-model-compliance
  • Building or editing Simulink models — use building-simulink-models
  • Digital thread configuration (digitalthread.settings)
  • Requirements authoring (slreq APIs)
  • Custom metric authoring (writing new metric algorithms)
  • Threshold customization

Workflow

A project must be open before using metric.Engine.

1. Create Engine

matlab
me = metric.Engine;

One instance per session is sufficient. Do not create multiple engines.

2. Attach Progress Monitor (Optional)

For progress visibility during updateArtifacts, attach a listener to the project's existing digital thread artifact service.

Setup: Add the skill's scripts/ directory to MATLAB's path before creating the monitor:

matlab
addpath("SKILL_DIR/scripts");
projectRoot = currentProject().RootFolder;
pm = AgentProgressMonitor(projectRoot);

Replace SKILL_DIR with the absolute path to this skill's directory on disk.

Ordering matters: Call addpath before AgentProgressMonitor(...). Adding the path after creating the monitor can trigger duplicate progress events from the artifact service re-indexing.

Script: scripts/AgentProgressMonitor.p — prints [dt XX%] message progress lines to stdout during artifact updates.

  • Input: projectRoot (string) — the project root folder
  • Output: AgentProgressMonitor handle object (clear it to stop listening)

The monitor stays active until cleared. Call updateArtifacts(me) normally — progress prints automatically while the monitor is in scope.

3. Update Artifacts

matlab
updateArtifacts(me);

Call updateArtifacts before collecting metrics that relate to testing (ModelUnitTesting, ModelUnitSILTesting, ModelUnitPILTesting, ProjectModelTesting). It refreshes traceability data so results reflect the current project state. Skipping this step produces stale or empty results for testing metrics.

For design/maintainability metrics (ModelMaintainability), updateArtifacts is not strictly required but is harmless.

4. Discover Metric IDs

matlab
ids = getAvailableMetricIds(me, App="DashboardApp", Dashboard="ModelUnitTesting");

Never hardcode metric IDs. IDs change across releases. Invalid IDs fail silently (warning + 0 results, no exception). Always discover first.

Valid Dashboard values: see references/metric-groups.md for the full list, introduction releases, and scoping rules.

To collect all installed metrics regardless of dashboard:

matlab
allIds = getAvailableMetricIds(me);

5. Execute Collection

matlab
execute(me, ids);

Runs the metric algorithms. In R2026a+, execute also returns results directly, but always call getMetrics for cross-release compatibility.

6. Retrieve Results

matlab
results = getMetrics(me, ids);

Returns a metric.Result array. Each element has properties: .Value, .MetricID, .Scope, .Artifacts, .Diagnostics.

7. Inspect and Present Results

Identify components with .Scope.Name — this is the model or component name each result belongs to. Do not rely on .Artifacts (frequently empty).

matlab
for k = 1:numel(results)
    componentName = results(k).Scope.Name;
    v = results(k).Value;
    if ismissing(v)
        fprintf("%s: No data\n", componentName);
    elseif isstruct(v) && isfield(v, 'Failed')
        fprintf("%s: %d passed, %d failed\n", componentName, v.Passed, v.Failed);
    elseif isnumeric(v) && isscalar(v)
        fprintf("%s: %g\n", componentName, v);
    elseif isstruct(v)
        fprintf("%s: struct(%s)\n", componentName, strjoin(string(fieldnames(v)), ", "));
    end
end

Group results by component when presenting to users:

matlab
scopeNames = arrayfun(@(r) string(r.Scope.Name), results(:));
for component = unique(scopeNames).'
    componentResults = results(scopeNames == component);
    fprintf("--- %s (%d metrics) ---\n", component, numel(componentResults));
    % ... summarize key metrics for this component
end

Value shapes vary by metric type and release. Common shapes include: scalar doubles, distribution structs, coverage breakdown structs, named count structs, and linkage ratios. Struct fields may themselves be structs or non-numeric — use disp or fprintf("%g", val) only after confirming isnumeric. See references/release-notes.md for cross-release differences.

Value semantics:

Metric patternValue meaningDo NOT assume
*Complexity, *CyclomaticComplexityUnbounded positive integer (higher = more complex)Not a percentage
*HalsteadDifficultyUnbounded positive double (higher = harder to maintain)Not a percentage
*DistributionStruct with BinCounts/BinEdges (histogram). BinEdges may be numeric or categorical (cell array of strings). Ratios may be NaN when counts are zero.Do not format NaN as a number; do not assume numeric bin edges
Overall*, *Count, *Lines, *BlocksRaw integer countsNot bounded

Coverage metrics return structs whose fields vary by metric prefix and release. Use fieldnames(v) to discover the shape. Common patterns on R2026a:

  • slcomp.mt.CoverageBreakdown: nested struct {Execution, Decision, Condition, MCDC, OverflowSaturation}, each with sub-fields {Achieved, Justified, Missed, AchievedOrJustified} (percentages 0–100)
  • UnitBoundary*CoverageBreakdown, Requirements*CoverageBreakdown: flat struct {Numerator, Denominator, Value} where Value is a ratio 0–1
  • *CoverageFragment: same shape as its *Breakdown counterpart on the same prefix

Do not assume a single coverage struct shape applies to all coverage metrics. Inspect with fieldnames before accessing fields.

Interpreting empty results:

ValueMeaningWhat to tell the user
[] (empty double)Prerequisite not met (e.g., tests not run, coverage not collected)"No test data — run tests first"
0Metric is applicable but the measured quantity is zeroReport as zero
ismissing(v)Metric does not apply to this componentOmit from summary or label "N/A"
Struct with all-empty sub-fields (e.g., .Achieved = [])Same as [] — prerequisite not met"No coverage data — run tests first"

Summarizing large result sets: Multi-dashboard collection can return 100+ results. Focus on headline metrics per dashboard rather than dumping all results:

DashboardHeadline metrics (present first)Detail metrics (show on request)
ModelMaintainabilityslcomp.OverallCyclomaticComplexity, slcomp.HalsteadDifficulty, slcomp.OverallBlocks*Distribution, per-language breakdowns
ModelUnitTestingslcomp.mt.TestStatusDistribution, slcomp.mt.CoverageBreakdownRequirements*, TestCase* distributions
ModelUnitSILTestingslcomp.sil.TestStatusDistribution, slcomp.sil.CoverageBreakdownB2B status, model-level coverage
ModelUnitPILTestingslcomp.pil.TestStatusDistribution, slcomp.pil.CoverageBreakdownB2B status, model-level coverage

Pattern: present one row per component with headline values, then offer detail on request.

8. Generate Report

When a user asks to "collect metrics" or "assess quality," prefer generateReport as the primary output — it produces a formatted, interactive view with proper component names and visual indicators. Use programmatic inspection (Step 7) when the user needs specific values extracted, when running in CI/headless mode, or when answering targeted questions about individual metrics.

matlab
generateReport(me, Dashboard="ModelUnitTesting", Type="html-file", Location=pwd);
ArgumentValues
DashboardSame values as getAvailableMetricIds
Type"pdf" (default), "html-file"
LocationOutput file path or directory (string). If a directory, the filename is auto-generated.
LaunchReporttrue (default) or false for CI

Available from R2021a. In R2026a+, Dashboard is mandatory.

Key Functions

All functions below are available from R2023a (the minimum release for this skill) unless noted otherwise.

FunctionPurpose
metric.EngineCreate engine instance (requires open project)
updateArtifacts(me)Refresh artifact traceability index
getAvailableMetricIds(me)Discover installed metric IDs
execute(me, ids)Run metric collection
getMetrics(me, ids)Retrieve collected results
generateReport(me, ...)Generate HTML/PDF report
getArtifactIssues(me)Return diagnostic warnings/errors
getArtifactErrors(me)Return artifact-level errors
executeDashboardMetrics(me, Dashboard=d)Convenience: discover + execute (no output; call getMetrics after). Does NOT accept App. Primarily for ProjectModelTesting. R2026a+

Patterns

Collect Metrics for a Single Dashboard

matlab
me = metric.Engine;
updateArtifacts(me);
ids = getAvailableMetricIds(me, App="DashboardApp", Dashboard="ModelUnitTesting");
execute(me, ids);
results = getMetrics(me, ids);

Collect Across Multiple Dashboards

Use the try-catch pattern in references/metric-groups.md § "Pattern: Safe Multi-Dashboard Collection".

Generate Report

matlab
me = metric.Engine;
ids = getAvailableMetricIds(me, App="DashboardApp", Dashboard="ModelMaintainability");
execute(me, ids);
generateReport(me, Dashboard="ModelMaintainability", Type="html-file", Location=pwd);

Do NOT build HTML manually with fopen/fprintf. Use the built-in generateReport.

Diagnose Artifact Issues

When metrics show errors or return empty results, use getArtifactIssues and getArtifactErrors to diagnose the problem — do not manually inspect project files, .prj internals, data dictionaries, or file paths as a workaround.

matlab
me = metric.Engine;
issues = getArtifactIssues(me);
errors = getArtifactErrors(me);
if ~isempty(issues)
    disp(issues);
end
if ~isempty(errors)
    disp(errors);
end

CI / Headless Usage

matlab
me = metric.Engine;
updateArtifacts(me);
ids = getAvailableMetricIds(me, App="DashboardApp", Dashboard="ModelUnitTesting");
execute(me, ids);
results = getMetrics(me, ids);
generateReport(me, Dashboard="ModelUnitTesting", Type="html-file", ...
    Location="reports", LaunchReport=false);

% Detect test failures via TestStatusDistribution (R2026a+)
% On R2026a+, BinEdges is a cell array of strings: {'Failed','Passed','Disabled','Not run','Untested'}
% On older releases, BinEdges may be numeric — strcmp will return scalar false; use index-based access instead.
hasFailures = false;
for k = 1:numel(results)
    v = results(k).Value;
    if isstruct(v) && isfield(v, 'BinCounts') && isfield(v, 'BinEdges') && iscell(v.BinEdges)
        failIdx = strcmp(v.BinEdges, 'Failed');
        if any(failIdx) && v.BinCounts(failIdx) > 0
            hasFailures = true;
            break;
        end
    end
end
if hasFailures
    exit(1);
end

The failure-detection logic above is reference code validated against slcomp.mt.TestStatusDistribution on R2026a. Struct fields and bin labels may differ across releases or metric IDs — use fieldnames(v) to confirm the shape before accessing fields programmatically.

Use LaunchReport=false in CI to prevent opening a browser. Use exit codes for pipeline integration.

For structured CI/CD pipelines that orchestrate metric collection alongside code generation, testing, standards checking, and other verification tasks — with automatic pipeline configuration generation for Jenkins, GitLab, GitHub Actions, or Azure DevOps — use the "CI/CD Automation for Simulink Check" support package (padv.builtin.task.CollectMetrics) and a processmodel.m file instead. That approach is worthwhile when you need multiple built-in tasks (e.g., RunModelStandards, GenerateCode, RunTestsPerModel, CollectMetrics) orchestrated together with pipeline generation, not for one-off metric collection.

Conventions

Always:

  • Call getAvailableMetricIds before execute — discover IDs at runtime
  • Call updateArtifacts before collecting testing/SIL/PIL metrics
  • Inspect .Value type before formatting (use isstruct, isnumeric, ismissing)
  • Use a single metric.Engine instance per session
  • Pass App="DashboardApp" when scoping getAvailableMetricIds by dashboard

Never:

  • Hardcode metric IDs — they change across releases and fail silently
  • Use getMetricResult or getMetricResults — correct method is getMetrics
  • Use metric.report.Report — correct method is generateReport on the engine
  • Use metric.config.getActiveConfiguration or reset() — these do not exist
  • Call getAvailableMetricIds as a static/package function — it is a method on the engine instance: getAvailableMetricIds(me, ...)

Prefer:

  • getAvailableMetricIds(me, App="DashboardApp", Dashboard=d) over unscoped getAvailableMetricIds(me) when targeting a specific assessment area
  • generateReport over manual HTML construction
  • getArtifactIssues/getArtifactErrors over manual project file inspection for diagnostics

Common Mistakes

MistakeWhy It FailsCorrect Approach
Hardcoding metric IDs like "TestCaseStatus" or "mathworks.metrics.CyclomaticComplexity"IDs change across releases; old IDs emit warning and return 0 results (no exception)Call getAvailableMetricIds(me, App="DashboardApp", Dashboard="...")
generateReport(me, ids, Type="table")Metric IDs are not a valid positional argument; Type="table" does not existgenerateReport(me, Dashboard="...", Type="html-file")
Skipping updateArtifactsTesting metrics return stale/empty traceability and coverage dataAlways call updateArtifacts(me) before testing metric collection
Assuming .Value is a scalar or enumMany metrics return structs (distributions, coverage breakdowns, named counts)Inspect with isstruct(v), fieldnames(v) before formatting
Calling getAvailableMetricIds as a static/package functionNot a static function — it is a method on a metric.Engine instancegetAvailableMetricIds(me) where me is an engine instance
executeDashboardMetrics(me, App="DashboardApp", Dashboard=d)executeDashboardMetrics does not accept App — only DashboardexecuteDashboardMetrics(me, Dashboard=d) — and still call getMetrics after (no output argument)
12+ steps of manual file inspection for diagnosticsBuilt-in APIs exist specifically for thisCall getArtifactIssues(me) and getArtifactErrors(me) first

References

  • references/metric-groups.md — valid Dashboard argument values, introduction releases, ID counts per release, multi-dashboard collection pattern. Consult when choosing which dashboard to scope to.
  • references/release-notes.md — API availability timeline, breaking changes across releases, conditional code patterns for cross-release support. Consult when writing code that must work across R2023a–R2026a.
  • references/documentation-links.md — authoritative MathWorks documentation URLs for metric.Engine and related APIs. Consult when the user needs links to official docs.
  • matlab-read-documentation skill (from matlab-core in the MATLAB Agentic Toolkit) — reads MathWorks documentation pages directly. Use this skill when you are stuck: repeated errors, unexpected API behavior, or needing to verify function signatures beyond what help provides. Start from https://www.mathworks.com/help/slcheck/ (Simulink Check, which covers metrics and the testing dashboard).

Copyright 2026 The MathWorks, Inc.


同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Simulink Collect Metrics」では何ができますか?

Collect and assess quality metrics for Simulink models using the metric.Engine API. Use when evaluating model design quality (maintainability, complexity, architecture) or testing completeness (unit testing, SIL, PIL, coverage, pass rates) after edits or test runs. Covers metric discovery, collection, report generation, and diagnostics. Triggers on: "collect metrics", "quality metrics", "metric.Engine", "testing metrics", "maintainability metrics", "SIL metrics", "PIL metrics", "what metrics are available", "assess quality", "coverage metrics", "generate metric report", "diagnose metric err...

TypingMindでSimulink Collect Metricsを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Simulink Collect Metricsはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにSimulink Collect Metricsをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/matlab/simulink-agentic-toolkit/tree/main/skills-catalog/verification-validation-and-test/simulink-collect-metricsを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Simulink Collect Metricsを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Simulink Collect Metricsで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもSimulink Collect Metricsを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Simulink Collect Metrics」は無料ですか?

matlabがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇