matlab-modernize-code

Rewrite deprecated MATLAB functions into current supported APIs.

883|109|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-modernize-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-modernize-code
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/matlab-software-development/matlab-modernize-code
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-modernize-code

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps you modernize MATLAB code by replacing deprecated functions and unsafe or outdated patterns, reducing “not recommended/to be removed” warnings and preventing future breakage.

Core Features & Use Cases

  • Modern API migrations: Replaces common legacy functions (for example csvread/xlsread/datenum/eval/subplot/uicontrol/optimset/trainNetwork) with current equivalents like readmatrix/readtable/datetime/tiledlayout/uifigure components/optimoptions/trainnet.
  • Detectors-driven modernization: Acts as the resolver skill intended to run after check_matlab_code flags deprecated or risky constructs.
  • Security- and correctness-focused fixes: Targets anti-patterns such as eval/str2num and other patterns that hurt maintainability, safety, or performance.

Quick Start

Ask your AI agent to modernize legacy MATLAB code by applying matlab-modernize-code after running check_matlab_code, producing a rewritten MATLAB file with deprecated APIs replaced by modern equivalents.

Frequently Asked Questions about matlab-modernize-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I update deprecated MATLAB functions to current APIs?

To update deprecated MATLAB functions, replace legacy calls like csvread, xlsread, and eval with modern equivalents such as readmatrix, readtable, and safer idioms. This code modernization process aligns with MathWorks best practices to prevent future breakage.

What is the best way to fix MATLAB "not recommended" or "to be removed" warnings?

Fixing MATLAB "not recommended" warnings involves refactoring legacy code by targeting specific deprecated symbols and anti-patterns. Rewriting outdated file I/O, graphics, and deep learning calls into supported APIs resolves these static analysis warnings.

How do I migrate legacy MATLAB deep learning code to current APIs?

To migrate legacy MATLAB deep learning code, replace outdated training functions like trainNetwork with current equivalents such as trainnet. This code migration ensures your deep learning models use supported, up-to-date APIs.

Can I automatically replace unsafe eval and str2num patterns in MATLAB?

Yes, you can replace unsafe eval and str2num patterns in MATLAB by applying security-focused code refactoring. This process rewrites risky evaluation anti-patterns into safer, maintainable idioms that improve code correctness and security.

Does modernizing MATLAB code require running static analysis checks first?

Modernizing MATLAB code is designed to follow static analysis checks that flag deprecated or risky constructs. Running code checks first identifies the specific outdated patterns to target for migration and refactoring.