
Matlab
Import and export CSV, spreadsheets, MAT files, images, and tables in MATLAB while your agent writes correct readtable/writematrix patterns.
Overview
MATLAB is an agent skill for the Build phase that documents MATLAB data import and export APIs—from CSV and spreadsheets through MAT files, images, and low-level I/O—for reproducible scientific pipelines.
Install
npx skills add https://github.com/k-dense-ai/scientific-agent-skills --skill matlabWhat is this skill?
- Covers text/CSV, spreadsheets, MAT files, images, tables, and low-level file I/O
- Documents readtable, readmatrix, readcell, readlines, and detectImportOptions workflows
- Includes write paths with delimiter, range, and header options
- Six top-level reference sections in the skill table of contents
- Six top-level reference sections (text/CSV, spreadsheets, MAT, images, tables, low-level I/O)
Adoption & trust: 554 installs on skills.sh; 27.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need reliable MATLAB read/write code for heterogeneous files but keep confusing readtable, readmatrix, and import-option APIs.
Who is it for?
Indie builders maintaining MATLAB scripts for research prototypes, lab automation, or numeric backends that exchange CSV/MAT artifacts.
Skip if: Greenfield web-only stacks with no MATLAB runtime, or teams that need Simulink/control-design guidance instead of file I/O.
When should I use this skill?
User is implementing MATLAB scripts that read or write CSV, spreadsheets, MAT files, images, or tables and needs correct API usage.
What do I get? / Deliverables
You get accurate, option-aware MATLAB snippets for ingesting and exporting tables, matrices, cells, and binary formats in analysis scripts.
- MATLAB import/export code blocks with options
- Table or matrix loading patterns aligned to file shape
Recommended Skills
Journey fit
Canonical shelf is Build because the skill is procedural reference for implementing data I/O in MATLAB-backed analysis or simulation code, not early discovery or GTM. Backend subphase matches numerical pipelines, file ingestion, and typed table handling that feed models or batch jobs rather than UI polish.
How it compares
Reference procedural snippets for MATLAB I/O—not a Python pandas migration skill or a live MCP data connector.
Common Questions / FAQ
Who is matlab for?
Solo builders and researchers who use MATLAB for numeric work and want an agent to generate correct import/export code from a structured reference.
When should I use matlab?
Use it in Build/backend when scripting ingestion of CSVs or spreadsheets, exporting results, or handling MAT and image files in a MATLAB pipeline.
Is matlab safe to install?
Check the Security Audits panel on this Prism page; the documented skill is reference material and typical use only needs local MATLAB file access.
SKILL.md
READMESKILL.md - Matlab
# Data Import and Export Reference ## Table of Contents 1. [Text and CSV Files](#text-and-csv-files) 2. [Spreadsheets](#spreadsheets) 3. [MAT Files](#mat-files) 4. [Images](#images) 5. [Tables and Data Types](#tables-and-data-types) 6. [Low-Level File I/O](#low-level-file-io) ## Text and CSV Files ### Reading Text Files ```matlab % Recommended high-level functions T = readtable('data.csv'); % Read as table (mixed types) M = readmatrix('data.csv'); % Read as numeric matrix C = readcell('data.csv'); % Read as cell array S = readlines('data.txt'); % Read as string array (lines) str = fileread('data.txt'); % Read entire file as string % With options T = readtable('data.csv', 'ReadVariableNames', true); T = readtable('data.csv', 'Delimiter', ','); T = readtable('data.csv', 'NumHeaderLines', 2); M = readmatrix('data.csv', 'Range', 'B2:D100'); % Detect import options opts = detectImportOptions('data.csv'); opts.VariableNames = {'Col1', 'Col2', 'Col3'}; opts.VariableTypes = {'double', 'string', 'double'}; opts.SelectedVariableNames = {'Col1', 'Col3'}; T = readtable('data.csv', opts); ``` ### Writing Text Files ```matlab % High-level functions writetable(T, 'output.csv'); writematrix(M, 'output.csv'); writecell(C, 'output.csv'); writelines(S, 'output.txt'); % With options writetable(T, 'output.csv', 'Delimiter', '\t'); writetable(T, 'output.csv', 'WriteVariableNames', false); writematrix(M, 'output.csv', 'Delimiter', ','); ``` ### Tab-Delimited Files ```matlab % Reading T = readtable('data.tsv', 'Delimiter', '\t'); T = readtable('data.txt', 'FileType', 'text', 'Delimiter', '\t'); % Writing writetable(T, 'output.tsv', 'Delimiter', '\t'); writetable(T, 'output.txt', 'FileType', 'text', 'Delimiter', '\t'); ``` ## Spreadsheets ### Reading Excel Files ```matlab % Basic reading T = readtable('data.xlsx'); M = readmatrix('data.xlsx'); C = readcell('data.xlsx'); % Specific sheet T = readtable('data.xlsx', 'Sheet', 'Sheet2'); T = readtable('data.xlsx', 'Sheet', 2); % Specific range M = readmatrix('data.xlsx', 'Range', 'B2:D100'); M = readmatrix('data.xlsx', 'Sheet', 2, 'Range', 'A1:F50'); % With options opts = detectImportOptions('data.xlsx'); opts.Sheet = 'Data'; opts.DataRange = 'A2'; preview(opts.VariableNames) % Check column names T = readtable('data.xlsx', opts); % Get sheet names [~, sheets] = xlsfinfo('data.xlsx'); ``` ### Writing Excel Files ```matlab % Basic writing writetable(T, 'output.xlsx'); writematrix(M, 'output.xlsx'); writecell(C, 'output.xlsx'); % Specific sheet and range writetable(T, 'output.xlsx', 'Sheet', 'Results'); writetable(T, 'output.xlsx', 'Sheet', 'Data', 'Range', 'B2'); writematrix(M, 'output.xlsx', 'Sheet', 2, 'Range', 'A1'); % Append to existing sheet (use Range to specify start position) writetable(T2, 'output.xlsx', 'Sheet', 'Data', 'WriteMode', 'append'); ``` ## MAT Files ### Saving Variables ```matlab % Save all workspace variables save('data.mat'); % Save specific variables save('data.mat', 'x', 'y', 'results'); % Save with options save('data.mat', 'x', 'y', '-v7.3'); % Large files (>2GB) save('data.mat', 'x', '-append'); % Append to existing file save('data.mat', '-struct', 's'); % Save struct fields as variables % Compression options save('data.mat', 'x', '-v7'); % Compressed (default) save('data.mat', 'x', '-v6'); % Uncompressed, faster ``` ### Loading Variables ```matlab % Load all variables load('data.mat'); % Load specific variables load('data.mat', 'x', 'y'); % Load into structure S = load('data.mat'); S = load('data.mat', 'x', 'y'); x = S.x; y = S.y; % List contents without loading whos('-file', 'data.mat'); vars = who('-file', 'data.mat'); ``` ### MAT-File Object (Large Files) ```matlab % Create MAT-file object for partial access m = matfile('data.mat'); m.Properties.Writable = true; % Read partial data x = m.bigArray(1:100, :); % First 100 rows only % Write partial data