本文へ移動
cccskills
無料GitHub で公開

simulink-single-precision-conversion

Converts a double-precision Simulink system or subsystem to single precision using DataTypeWorkflow.Single (Fixed-Point Designer). The single conversion replaces all user-specified double-precision data types, as well as output data types that compile to double precision, with single-precision data types. Use this skill when converting Simulink systems to single precision, reducing memory usage of a Simulink system, optimizing for embedded targets. Do NOT use for standalone MATLAB .m code single conversion.

インストール方法を見る

含まれるファイル(4)

  • SKILL.md8.3 KB
  • manifest.yaml596 B
  • references/edge-cases.md6.8 KB
  • references/reporting-format.md4.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Single-Precision Conversion for Simulink Models (Fixed-Point Designer)

Toolbox: Fixed-Point Designer Function: DataTypeWorkflow.Single.convertToSingle

Converts user-specified double-precision data types — across block settings, Stateflow chart settings, signal objects, and bus objects — to single precision. Boolean, built-in integer (int8, uint8, int16, …), and fixed-point types are left unchanged.

When to Use

  • Converting a Simulink model (.slx) or subsystem from double-precision to single-precision
  • Reducing memory footprint for embedded hardware with native single-precision support
  • Batch/CI conversions, checking conversion compatibility, or verifying no stowaway doubles remain
  • Summarizing the single conversion compatibility report and conversion result for the user in plain language

When NOT to Use

  • Standalone MATLAB .m code — use the convertToSingle function with coder.config('single') instead
  • Fixed-point data type optimization — use DataTypeWorkflow.Converter instead
  • Approximating a function or shrinking Lookup Table blocks with LUTs — use simulink-optimize-lookup-tables instead

Public API

ConversionReport = DataTypeWorkflow.Single.convertToSingle(systemToConvert)
  • systemToConvert (char) — full block path of the loaded model or subsystem (e.g. 'myModel' or 'myModel/Controller').
  • ConversionReport (struct) — compatibility check, converted items, and verification status (see field tables below).

Worked example: openExample("fixedpoint/ConvertSystemToSinglePrecisionExample")

Rules

  1. Open with open_system(modelName), not load_system — the user must see the diagram before/after.
  2. Never call save_system on your own — saving destroys the double-precision baseline and blocks meaningful re-runs. Leave the model dirty. This holds even when the user asks you to "make it stick," "persist it," or "do everything end-to-end" — that is not consent to auto-save. In that case, state plainly that you will not save the model yourself, explain that saving overwrites the double-precision baseline, and ask the user to confirm or run save_system themselves. Only persist after the user explicitly confirms saving specifically (not merely a general "do it all" request).
  3. The compatibility check runs inside convertToSingle; read its results from report.CheckInfo (it is not a separate call).
  4. Get the user's explicit consent before converting. If the model path, subsystem, or scope is ambiguous, ask — do not guess. When the user says "my model" without naming one, ask which model; never adopt a .slx you happen to find in the working directory (an example or fixture file is not the user's intended model). Only run the conversion once the user has named the model.
  5. Always inspect report.VerifyInfo.StowawayDblBlks afterward — remaining stowaway doubles mean the conversion is incomplete. Fix them at the source (retype locked-double blocks, set Stateflow data to single, or widen the SUD scope) and re-run convertToSingle. Do not recommend hand-inserting single(...) casts or Data Type Conversion blocks on the offending signals — that hides the double instead of eliminating it.
  6. Assign the report to a local variable (report = ...;) — don't pollute the base workspace or echo the raw struct.

Report Structure

The tool runs check → convert → verify, populating three sub-structs on the report.

report.CheckInfo

FieldDescription
readyLogical — true if the system can be converted - only read ConvertInfo/VerifyInfo when this is true.
errError info (empty on success)
IncompatibleBlksCell array of DataTypeWorkflow.Single.Result — blocks not supporting single precision (see block-name note below)
UnsupportedBlksCell array of DataTypeWorkflow.Single.Result — blocks unsupported by the conversion tool (with ErrorMsgs)
DTLockedDblBlksBlocks with locked double data types (do not block conversion)
StowawayDblBlksBlocks generating double operations found during the check
TLSSettingsModels whose Target Language Standard was updated to C99
DTOSettingsSystems whose Data Type Override was reset
SolverSettingsModels whose variable-step solver was changed to fixed-step
configSettingsConfig params updated (e.g. GenerateComments, ParameterPrecisionLossMsg)
memoryUse.BeforeValuePer-parameter memory table; column RuntimeMemory (bytes) before conversion

How to extract block names from the diagnostic list. IncompatibleBlks, UnsupportedBlks, StowawayDblBlks, and DTLockedDblBlks are cell arrays of DataTypeWorkflow.Single.Result objects — not block-path strings. Get the readable block path from each element's ID via getDisplayName(). Do not call get_param, getfullname, or string() on the elements: that errors with "The first input to get_param must be of type 'double', 'char' or 'cell'.":

for k = 1:numel(report.CheckInfo.IncompatibleBlks)
    r = report.CheckInfo.IncompatibleBlks{k};
    fprintf('  %s\n', r.ID.getDisplayName());   % e.g. 'myModel/Integrator'
    if ~isempty(r.ErrorMsgs)
        fprintf('    %s\n', strjoin(string(r.ErrorMsgs), '; '));
    end
end

report.ConvertInfo

Records what the converter actually did.

FieldDescription
readyLogical — true if the convert step ran cleanly
errError info; empty ([]) on success
resultsCell array of fxptds.BlockResult — the blocks/signals changed from double to single

report.VerifyInfo

FieldDescription
StowawayDblBlksBlocks still generating double operations after conversion
memoryUse.AfterValuePer-parameter memory table; column RuntimeMemory (bytes) after conversion

The check phase validates the Target Language Standard, Data Type Override, incompatible blocks, stowaway doubles, data-type-locked doubles, and solver settings — and auto-updates several of them. The tool handles TLS→C99, DTO cleanup, and solver changes automatically; you do not need to set these manually. See references/edge-cases.md for the full auto-update behavior, error identifiers, and edge cases:

  • Model not loaded / invalid path (Simulink:Commands:InvSimulinkObjectName); update-diagram failures (DataTypeWorkflow:Single:UpdateDiagramFailed)
  • Incompatible blocks (continuous blocks, MATLAB System blocks) and unsupported MATLAB Function Blocks (globals, MCOS classes, Simulink function calls)
  • Auto-updates (TLS, DTO, solver, config), model-reference scope handling, idempotency, and cleanup on model close

Generating the Conversion Report

After convertToSingle returns, summarize the result for the user in plain language — do not dump the raw struct. Put the exact API call used at the top for traceability.

For the required output sections, empty-report fallback, reporting conventions, and the Embedded Coder readiness-check follow-up, see references/reporting-format.md.


Prerequisites & Limitations

  • Requires MATLAB, Simulink, and Fixed-Point Designer; the model must be loaded.
  • The conversion engine is a singleton — only one conversion session can be active at a time.
  • MATLAB Function Blocks with complex logic and model references may need individual review — see references/edge-cases.md.

Copyright 2026 The MathWorks, Inc.


レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Author or upgrade Model Advisor checks for Simulink and System Composer models. Covers the full lifecycle: guideline authoring, check specification, Model Advisor check implementation, and qualification testing. Use when creating new checks (edit-time, standard batch, config-parameter, auto-fix), converting legacy StyleOne/StyleTwo/StyleThree checks to modern DetailStyle, creating a guideline for modeling, enforcing a modeling rule, or testing/qualifying a check. Triggers on any modeling constraint (e.g., "blocks shall...", "signals must match...", "parameters shall be set to...").

日本語の概要は準備中です。原文の説明を表示しています。

matlab/simulink-agentic-toolkit1,2142026年10月8日 更新

Synthesize new waveforms from scratch for Simulink inports using createInputDataset. Use ONLY when the user asks to generate, create, or synthesize signals (step, ramp, sine, chirp, pulse, noise) to populate a Dataset for External Inputs or Signal Editor. Covers timeseries and timetable formats with correct data type, interpolation, units, and dimensions. Also covers function-call and trigger inport timing setup. Do NOT use when the user wants to load, import, or read existing data from files (MAT, CSV, spreadsheet) — even if that data will be used as model input. Do NOT use for running simulations or plotting outputs.

日本語の概要は準備中です。原文の説明を表示しています。

matlab/simulink-agentic-toolkit1,2142026年10月8日 更新

Common steps for building multi-layer system architecture models using System Composer. Use when implementing architecture models or when interacting with interface dictionaries, allocation sets, stereotypes, and requirements for architecture components.

日本語の概要は準備中です。原文の説明を表示しています。

matlab/simulink-agentic-toolkit1,2142026年10月8日 更新

Builds and edits Simulink, System Composer, Stateflow, and Simscape models. Use when modifying model structure, parameters, ports, connections, or Stateflow chart internals.

日本語の概要は準備中です。原文の説明を表示しています。

matlab/simulink-agentic-toolkit1,2142026年10月8日 更新

Use this skill when the user asks to check Simulink model compliance against a standard (MISRA, MAB, JMAAB, ISO, DO, IEC, EN, CERT C/CWE, AUTOSAR, Simulink Code Inspector (SLCI)), wants to run Model Advisor checks, or needs a compliance report with fix suggestions. For JMAAB/MAB, supplement deterministic checks with agentic review of uncheckable guidelines.

日本語の概要は準備中です。原文の説明を表示しています。

matlab/simulink-agentic-toolkit1,2142026年10月8日 更新

Guide users through creating and managing .satk/block-policy.json for controlling which blocks the agent can use, which are excluded, and which block parameters the agent should not modify. Use when setting up block usage policy for a project.

日本語の概要は準備中です。原文の説明を表示しています。

matlab/simulink-agentic-toolkit1,2142026年10月8日 更新

matlab のスキルをすべて見る

このスキルの問題を報告する