본문으로 건너뛰기
cccskills
무료GitHub에 공개

matlab-modernize-code

Modernize removed or discouraged MATLAB functions and patterns. Use when the check_matlab_code MCP tool reports that a function "is not recommended", "will be removed in a future release", or "has been removed" — at any severity (info, warning, or error) — when migrating legacy code, or when replacing removed or discouraged APIs with current equivalents. Also applies to discouraged patterns Code Analyzer does not flag (containers.Map, bsxfun, str2num, eval, clear all) and to removed or discouraged functions such as trainNetwork, csvread, xlsread, datenum, guide, svmtrain, ltln2val, webmap.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Excel
설치 방법 보기

포함된 파일(12)

  • SKILL.md9.7 KB
  • manifest.yaml1.1 KB
  • references/audio-video-guidance.md9.4 KB
  • references/communications-guidance.md8.5 KB
  • references/control-systems-guidance.md5.0 KB
  • references/core-functions-guidance.md22.1 KB
  • references/deep-learning-guidance.md3.3 KB
  • references/image-processing-guidance.md6.9 KB
  • references/mapping-guidance.md14.5 KB
  • references/optimization-guidance.md6.0 KB
  • references/signal-processing-guidance.md5.0 KB
  • references/statistics-ml-guidance.md8.0 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Code Modernization

Replace removed or discouraged MATLAB functions and anti-patterns with modern equivalents. This skill is the resolver — the MCP tool check_matlab_code (MATLAB's Code Analyzer) is the detector.

Terms used in this skill:

  • Removed — the function is no longer in MATLAB; calling it errors.
  • Discouraged — the function still works, but a better API exists. It may or may not be slated for removal in a future release.

When to Use

  • check_matlab_code reports a lifecycle diagnostic — any of these three wordings, matched case-insensitively (STRMATCH is not recommended is the same signal as the lowercase form):
    • 'X' is not recommended... (severity: info)
    • 'X' will be removed in a future release... (severity: warning)
    • 'X' has been removed... (severity: error — the code errors today)
  • Code uses a discouraged pattern Code Analyzer does not flag — e.g. containers.Map, bsxfun, str2num, eval, clear all — scan the source, not just the diagnostics (see Conventions)
  • User asks to modernize, migrate, or update old MATLAB code
  • Code uses functions listed in the quick reference table below
  • After static analysis reveals removed or discouraged API usage
  • Writing new code in a domain that has known removed or discouraged patterns

When NOT to Use

This skill swaps removed or discouraged APIs for modern equivalents. It does not:

  • Review code quality broadly
  • Debug runtime behavior (removed-function errors excepted — those are modernization fixes)
  • Optimize already-correct code for speed → hand off to matlab-optimize-performance
  • Write or migrate function input/output validation (arguments blocks, inputParser/validateattributes → mustBe* validators, repeating args, name-value forwarding) → hand off to matlab-validate-function-arguments

Quick Reference: Removed, Discouraged & Anti-Patterns

TopicRecommendationSinceCategoryRationale
csvread / dlmreadreadmatrixR2019aFile I/O
csvwrite / dlmwritewritematrixR2019aFile I/O
xlsreadreadtable, readmatrixR2019aFile I/O
xlswritewritetable, writematrixR2019aFile I/O
datenum / datestr / nowdatetime (use string/char to format)R2022bDate/Time (Not recommended)Flagged by Code Analyzer
eval / evalc / evalinDynamic field names s.(name), function handles / feval, cells for sequential names—Anti-patternNot compiled (slow); can overwrite workspace vars; hard to debug; injection risk
str2numstr2num(text, Evaluation="restricted")R2022aSecurityUnrestricted form runs input via eval (injection risk); see references
uicontroluibutton, uidropdown, etc.R2016aUI/App
guideappdesignerR2025aUI (Removed)
strmatchstartsWith, matchesR2019bStrings
clear allclearvars—WorkspaceClears functions from memory; forces recompilation

datestr nuance: datestr's job was to format a date as text, so its modern replacement is string(dt) / char(dt) or setting dt.Format — not a bare datetime(...) call. Use datetime to replace datenum/now (the numeric/serial-date path). Neither is removed; both are Code Analyzer "not recommended" as of R2022b.

s = datestr(t, 'yyyy-mm-dd HH:MM:SS');          % old
s = string(t, 'yyyy-MM-dd HH:mm:ss');           % new — note the specifiers change:
                                                % datetime uses MM=month, mm=minute (datestr had mm=month, MM=minute)

Modern Design Patterns

Prefer these in all new code:

Table-Based Workflows

data = readtable('sensors.csv');
data.Timestamp = datetime(data.Timestamp);
data.Status = categorical(data.Status);
recentData = data(data.Timestamp > datetime('today') - days(7), :);
summary = groupsummary(recentData, 'SensorID', 'mean', 'Value');

String Arrays (not char arrays)

name = "John";                        % not 'John'
names = ["John", "Jane", "Bob"];      % not {'John','Jane','Bob'}
fullName = firstName + " " + lastName; % not [first,' ',last]
idx = contains(names, "Jo");          % not cellfun + strfind

Arguments Block (not nargin/varargin)

function result = processData(data, options)
    arguments
        data (:,:) double
        options.Method (1,1) string {mustBeMember(options.Method, ["fast","accurate"])} = "fast"
        options.Verbose (1,1) logical = false
    end
end

Key Migrations

File I/O: csvread/xlsread → readmatrix/readtable

% Old                          → Modern
M = csvread('data.csv');       % M = readmatrix("data.csv");
M = dlmread('data.txt','\t'); % M = readmatrix("data.txt", Delimiter="\t");
[n,t,r] = xlsread('f.xlsx');  % T = readtable("f.xlsx");
csvwrite('out.csv', M);       % writematrix(M, "out.csv");
xlswrite('out.xlsx', data);   % writetable(T, "out.xlsx");

eval → Structured Alternatives

Avoid eval/evalc/evalin: the text isn't compiled (slower), can silently overwrite workspace variables, and is hard to read/debug. Match the intent to a construct — see references/core-functions-guidance.md for the full set (sequential names, sprintf filenames, try/catch).

% Old: eval([varName ' = 42;']);          -> dynamic field name
s.(varName) = 42;

% Old: result = eval(['process_' method '(x)']);  -> handle dispatch table
handlers.fast = @processFast;
handlers.slow = @processSlow;
result = handlers.(method)(x);

% Old: for n=1:10, eval(['A' int2str(n) '=magic(n);']); end  -> index a cell
A = cell(10,1);
for n = 1:10, A{n} = magic(n); end

References

Load these when working in a specific domain:

Load when...Reference
Core MATLAB functions (file I/O, strings, UI); security anti-patterns (eval/str2num), containers.Map→dictionary, bsxfun→implicit expansionreferences/core-functions-guidance.md
Deep Learning (trainNetwork→trainnet, LayerGraph/SeriesNetwork/DAGNetwork→dlnetwork, classify, activations)references/deep-learning-guidance.md
Signal processing functionsreferences/signal-processing-guidance.md
Audio/video I/O migration (wavread, aviread)references/audio-video-guidance.md
Optimization toolbox (optimset, optimtool)references/optimization-guidance.md
Control systems plot optionsreferences/control-systems-guidance.md
Image processing ROI objectsreferences/image-processing-guidance.md
Statistics/ML (svmtrain, dataset, classregtree)references/statistics-ml-guidance.md
Communications System objectsreferences/communications-guidance.md
Mapping Toolbox (webmap, wmmarker, wmline, geotiffread, mfwdtran, makerefmat)references/mapping-guidance.md

Conventions

  • Always run check_matlab_code first — let static analysis find removed or discouraged usage
  • After running it, scan the source for patterns the Code Analyzer may under-flag: str2num (framed only as a perf tip); containers.Map (see next point).
  • containers.Map is not flagged by check_matlab_code. A plain script using it returns zero diagnostics; a containers.Map property default surfaces only a handle-default-sharing warning ("all instances share the same object data"). The detect-first workflow will not find this migration — treat any containers.Map usage, and that handle-sharing warning on a property, as a containers.Map→dictionary trigger.
  • subplot is not deprecated or discouraged. It is fully supported and is never flagged by check_matlab_code. tiledlayout/nexttile is a preferred alternative for new code, not a required migration — do not tell the user to replace working subplot code.
  • Fix removed or discouraged patterns before other code quality issues
  • When writing new code, use the modern pattern from the start — don't write legacy code and fix it later
  • A 'X' has been removed diagnostic (severity error) means the function errors today — treat it as a break-fix modernization, ahead of "not recommended" (info) and "will be removed" (warning) cases
  • When migrating, test the modern replacement against the old behavior to confirm equivalence
  • Legacy .m files are often Windows-1252 encoded. After an edit, verify non-ASCII characters (°, µ, ±) survived — a diff showing an unrelated one-line change on a comment or string is usually a re-encoded byte, not your edit.
  • Consult the domain-specific reference file for detailed migration patterns with code examples

Copyright 2026 The MathWorks, Inc.


리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guide for accessing financial and economic data in MATLAB using the Datafeed Toolbox. Covers Bloomberg (market data via bloomberg/blp/bloombergHypermedia), FRED (Federal Reserve economic data via fredrs), Haver Analytics (economic data via haver/haverdirect/haverview), and LSEG Datastream (historical data via datastreamws). Use when connecting to any of these data providers from MATLAB.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

Read BEFORE writing any code that adds Additive White Gaussian Noise (AWGN) to signals and converts between SNR, Eb/No, Es/No, and per-subcarrier SNR for communications simulations, using awgn(), convertSNR(), berawgn(). The default MATLAB patterns for AWGN (e.g., 'measured' option, manual SNR formulas) produce subtly incorrect results. This skill specifies the correct calling conventions, required function usage, and critical anti-patterns that must be avoided.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

Analyze AMS waveform data using Mixed-Signal Blockset utilities: phase noise measurement, clock jitter, anti-aliased resampling, timing measurements, lock time, INL/DNL, ADC/DAC calibration, HSpice import. Use when analyzing time-domain voltage from PLL/VCO/clock simulations, measuring phase noise from variable-step solver output, computing jitter, or resampling non-uniform data.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

Design and analyze electrically large antenna structures using MATLAB Antenna Toolbox. Covers reflector antennas (parabolic, Cassegrain, Gregorian, offset, corner, cylindrical, spherical, custom STL), reflectarrays and reconfigurable intelligent surfaces (RIS), antennas installed on platforms (vehicles, aircraft, ships, satellites), and radar cross section (RCS) analysis. Includes solver selection (MoM-PO, PO, MoM, FMM), mesh control, and GPU acceleration. Use when the user wants to design a dish/reflector antenna, reflectarray, analyze an antenna on a platform, or compute RCS.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

Analyze data using MATLAB. Use when the task involves tables, timetables, time-series data, numeric arrays, sensor matrices, or gridded data — including but not limited to exploring, row filtering, sorting, cleaning, transforming, aggregating, smoothing, padding, trimming, and answering questions about data. MATLAB provides extensive, easy-to-use built-in functions for these workflows with no additional products required.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

S-parameters, insertion loss, fields, currents, mesh control, and solver selection for RF PCB performance validation. TRIGGER: user asks to compute S-parameters, analyze insertion/return loss, extract fields or currents, compare MoM vs FEM, or control mesh for any RF PCB component. Invoke BEFORE writing sparameters() or solver code — API is non-obvious. SKIP: designing or creating components (use the specific matlab-design-pcb-* skill), material/stackup setup only (use matlab-manage-pcb-material), optimization sweeps (use matlab-optimize-pcb-design), PDN/IR-drop analysis (use matlab-analyze-pcb-pdn).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

matlab/matlab-agentic-toolkit1.2천2026년 10월 14일 업데이트

matlab의 스킬 모두 보기

이 스킬의 문제 신고