matlab/matlab-agentic-toolkit / skills-catalog/matlab-software-development/matlab-modernize-code
matlab-modernize-code
VerifiedModernize 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.7 KB |
| manifest.yaml | config | 1.1 KB |
| references/audio-video-guidance.md | markdown | 9.4 KB |
| references/communications-guidance.md | markdown | 8.5 KB |
| references/control-systems-guidance.md | markdown | 5.0 KB |
| references/core-functions-guidance.md | markdown | 22.1 KB |
| references/deep-learning-guidance.md | markdown | 3.3 KB |
| references/image-processing-guidance.md | markdown | 6.9 KB |
| references/mapping-guidance.md | markdown | 14.5 KB |
| references/optimization-guidance.md | markdown | 6.0 KB |
| references/signal-processing-guidance.md | markdown | 5.0 KB |
| references/statistics-ml-guidance.md | markdown | 8.0 KB |
references/deep-learning-guidance.md
View on GitHub# Deep Learning Toolbox Modernization
## Quick Reference: Function Mappings
| Topic | Recommendation | Since | Status |
|---|---|---|---|
| `trainNetwork` | `trainnet` | R2024a | Not Recommended |
| `LayerGraph` / `SeriesNetwork` / `DAGNetwork` | `dlnetwork` | R2024a | Not Recommended |
| `classify` | `minibatchpredict` + `scores2label` | R2024a | Not Recommended |
| `activations` | `minibatchpredict` (`Outputs=`) | R2024a | Not Recommended |
---
## trainNetwork → trainnet
**Status:** Not recommended as of R2024a
**Old Pattern (Avoid):**
```matlab
layers = [
imageInputLayer([28 28 1])
convolution2dLayer(3,8,'Padding','same')
reluLayer
fullyConnectedLayer(10)
softmaxLayer
classificationLayer];
net = trainNetwork(XTrain, YTrain, layers, options);
```
**Modern Pattern (Use This):**
```matlab
layers = [
imageInputLayer([28 28 1])
convolution2dLayer(3, 8, Padding="same")
reluLayer
fullyConnectedLayer(10)
softmaxLayer];
net = trainnet(XTrain, YTrain, layers, "crossentropy", options);
```
**Why Modern is Better:**
- `trainnet` supports `dlnetwork` objects with broader architecture support
- Enables easier loss function specification (built-in or custom)
- Returns unified `dlnetwork` data type
- Typically faster than `trainNetwork`
- Supports networks imported from external platforms (PyTorch, TensorFlow)
**Key Difference:** Specify loss function explicitly instead of using output layers like `classificationLayer`.
---
## LayerGraph, SeriesNetwork, DAGNetwork → dlnetwork
**Status:** Not recommended as of R2024a
**Old Pattern (Avoid):**
```matlab
lgraph = layerGraph(layers);
lgraph = addLayers(lgraph, newLayers);
lgraph = connectLayers(lgraph, 'layer1', 'layer2');
net = trainNetwork(data, lgraph, options);
```
**Modern Pattern (Use This):**
```matlab
net = dlnetwork(layers);
% Or for complex architectures:
net = dlnetwork;
net = addLayers(net, layers1);
net = addLayers(net, layers2);
net = connectLayers(net, 'layer1', 'layer2');
net = initialize(net);
% Train with trainnet
net = trainnet(XTrain, YTrain, net, "crossentropy", options);
```
**Migration from existing networks:**
```matlab
% Convert DAGNetwork or SeriesNetwork to dlnetwork
dlnet = dag2dlnetwork(trainedNet);
```
**Why Modern is Better:**
- Unified data type for building, prediction, training, visualization, compression, and verification
- Supports custom training loops
- Better interoperability with external frameworks
- Required for modern training functions
---
## classify → minibatchpredict + scores2label
**Status:** Not recommended as of R2024a
**Old Pattern (Avoid):**
```matlab
YPred = classify(net, XTest);
```
**Modern Pattern (Use This):**
```matlab
scores = minibatchpredict(net, XTest);
YPred = scores2label(scores, classNames);
```
**For probability scores:**
```matlab
scores = minibatchpredict(net, XTest);
[YPred, probs] = scores2label(scores, classNames);
```
---
## activations → minibatchpredict with Outputs
**Status:** Not recommended as of R2024a
**Old Pattern (Avoid):**
```matlab
act = activations(net, X, 'conv1');
```
**Modern Pattern (Use This):**
```matlab
act = minibatchpredict(net, X, Outputs='conv1');
```
**Multiple layer outputs:**
```matlab
[act1, act2] = minibatchpredict(net, X, Outputs={'conv1', 'fc1'});
```
----
Copyright 2026 The MathWorks, Inc.
----
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |