domains / science / matlab-octave-computing / matlab

matlab

Skill card

combined

The K-Dense-AI copy is a distinct, more rigorous procedure focused on review, migration, safety, and provenance, while the other two copies are near-identical quick-reference guides for writing MATLAB/Octave scripts. The K-Dense copy adds material steps (clarify target, static inventory, safety boundary, execution plan, provenance) and constraints (license gate, no untrusted execution) that the others lack. The other two copies add a routing boundary (foryourhealth111) and a broader set of code examples (zLanqing/foryourhealth111) that the K-Dense copy does not include. Crowning one would hide a real alternative workflow.

Repositories

RepositoryPath
zLanqing/codex-claude-academic-skillsscientific-toolkit-skill/references/scientific-skills/matlab/SKILL.md
K-Dense-AI/scientific-agent-skillsskills/matlab/SKILL.md
foryourhealth111-pixel/Vibe-Skillsbundled/skills/matlab/SKILL.md

Other copies

RoleRepositoryPath
peerzLanqing/codex-claude-academic-skillsscientific-toolkit-skill/references/scientific-skills/matlab/SKILL.md
peerK-Dense-AI/scientific-agent-skillsskills/matlab/SKILL.md
peerforyourhealth111-pixel/Vibe-Skillsbundled/skills/matlab/SKILL.md

Combined skill

# MATLAB and GNU Octave

## Routing
Use this skill only when the user explicitly asks for MATLAB, Octave, Simulink, `.m` scripts, or MATLAB-specific tooling. Do not use it for generic NumPy, Python matrix work, or Jupyter notebooks unless MATLAB or Octave is explicit.

## Product and License Gate
- MATLAB is proprietary. Do not assume MATLAB, toolboxes, or add-ons are installed or licensed.
- MATLAB Runtime is not MATLAB; it cannot run arbitrary source or host MATLAB Engine for Python.
- GNU Octave is free software under GPLv3+. Octave packages are not MATLAB toolboxes.
- Ask which runtime, release, platform, installed products, and license context the user has. Treat availability as unknown until confirmed.

## Safety Boundary
Never run an untrusted `.m`, `.mlx`, MEX binary, MAT file, or generated artifact without inspection and explicit approval. Treat `eval`, `system`, `py.*`, MEX, `load`, and object deserialization as execution surfaces. Do not use Python pickle for exchange.

## Default Workflow
1. Clarify target: record MATLAB release or Octave version, OS/architecture, required products, expected inputs/outputs, numerical tolerances, and whether execution is authorized.
2. Inventory statically: scan `.m` files, opaque artifacts, project paths, and MAT headers before any runtime loads them.
3. Choose code form: prefer functions with an `arguments` block for automation. Use scripts only for controlled orchestration.
4. Make semantics explicit: record shapes, classes, units, missing-value rules, indexing, RNG algorithm/seed, tolerances, and output formats.
5. Test without hidden state: keep fixtures synthetic, paths project-local, and tests independent of base-workspace residue.
6. Plan execution: generate an argv plan, review startup/path effects and licenses, and launch only after explicit approval.
7. Capture provenance: hash named inputs/code and record release, products, RNG policy, tolerances, and command plan.

## Quick Start

**Running MATLAB scripts:**
```bash
matlab -nodisplay -nosplash -r "run('script.m'); exit;"
```

**Running Octave scripts:**
```bash
octave script.m
```

**Install GNU Octave:**
```bash
# macOS
brew install octave
# Ubuntu/Debian
sudo apt install octave
```

## Core Capabilities

### Matrix Operations
```matlab
A = [1 2 3; 4 5 6; 7 8 9];
v = 1:10;
I = eye(3);
B = A';
C = A * B;
D = A .* B;
E = A \ b;
```

### Linear Algebra
```matlab
[V, D] = eig(A);
[U, S, V] = svd(A);
[L, U] = lu(A);
[Q, R] = qr(A);
x = A \ b;
```

### Plotting and Visualization
```matlab
x = 0:0.1:2*pi;
y = sin(x);
plot(x, y, 'b-', 'LineWidth', 2);
xlabel('x'); ylabel('sin(x)');
title('Sine Wave');
grid on;
saveas(gcf, 'plot.png');
```

### Data Import/Export
```matlab
T = readtable('data.csv');
writetable(T, 'output.csv');
save('data.mat', 'A', 'B');
load('data.mat');
```

### Control Flow and Functions
```matlab
if x > 0
    disp('positive');
end
for i = 1:10
    disp(i);
end
function y = myfunction(x, n)
    y = x.^n;
end
```

### Statistics and Data Analysis
```matlab
m = mean(data);
s = std(data);
R = corrcoef(X, Y);
p = polyfit(x, y, 1);
```

### Differential Equations
```matlab
f = @(t, y) -2*y;
[t, y] = ode45(f, [0 5], 1);
```

### Signal Processing
```matlab
Y = fft(signal);
b = fir1(50, 0.3);
y_filtered = filter(b, 1, signal);
```

## Language and Data Checklist
- MATLAB uses 1-based, column-major indexing.
- Scripts share the caller/base workspace; functions have local workspaces.
- Avoid `clear all`, broad `addpath(genpath(...))`, dependence on `pwd`, and global variables.
- Validate sizes, classes, and values in `arguments` blocks.
- A main function file should match the main function name.