Generated banner for Matlab Analyze Data
Generated logo for Matlab Analyze Data

Matlab Analyze Data

MathWorksOfficialCreated by MathWorks

  • Skill
  • Tool integration
  • Data and AI
  • BSD-2-Clause
  • No issues found

From the author

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.
— the description by MathWorks

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured approach to data analysis in MATLAB, focusing on modern, idiomatic practices for handling tables, timetables, and numeric arrays. It emphasizes the use of built-in functions for cleaning, transforming, aggregating, and exploring data, while providing guidance on avoiding legacy patterns and common pitfalls. The skill is designed to help users efficiently answer questions about their data by leveraging MATLAB's native capabilities for data manipulation and statistical analysis.

What it does

  • Generates idiomatic MATLAB code for tabular and time-series data analysis.
  • Provides guidance on cleaning data, including handling missing values and outliers.
  • Supports complex data transformations like filtering, sorting, and reshaping.
  • Facilitates grouped statistics and aggregation using modern functions.
  • Offers techniques for smoothing, trend detection, and pattern analysis.
  • Includes best practices for working with numeric arrays and gridded data.

When to use it

  • When you need to explore, clean, or transform tabular or time-series data.
  • When performing statistical aggregations or group-based analysis.
  • When analyzing sensor matrices or gridded numeric data.
  • When you need to detect patterns, trends, or outliers in your datasets.
  • When you need to answer specific questions about data structure or content.

Advantages

  • Promotes the use of modern, performance-optimized MATLAB functions.
  • Reduces bugs by providing clear guidance on handling missing data and types.
  • Ensures consistent and readable code through idiomatic patterns.
  • Provides direct access to documentation for key data analysis functions.
  • Helps avoid common pitfalls associated with legacy MATLAB syntax.

Usage examples

“How do I calculate the mean sales per region from my table T?”
The agent will provide code using groupsummary(T, 'Region', 'mean', 'Sales') to efficiently compute the requested statistics.
“Clean the missing values in my timetable by forward-filling.”
The agent will generate code using fillmissing(TT, 'previous') to handle gaps in the time-series data.
“Find the top 5 rows in my table based on the 'Revenue' column.”
The agent will suggest using topkrows(T, 5, 'Revenue') for a clean and efficient retrieval.
“How do I smooth a noisy signal in a numeric array?”
The agent will recommend using smoothdata(X, 'movmean', windowSize) to apply a moving average filter.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/matlab/matlab-analyze-data/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip matlab-analyze-data.zip -d .agents/skills

Documentation by MathWorks

MATLAB Data Analysis

Generate idiomatic MATLAB code for tabular data analysis tasks using tables and timetables.

When to Use

  • Any task involving tabular data: exploring, cleaning, transforming, or aggregating tables

  • Time-series analysis: resampling, synchronizing, trend detection, smoothing

  • Answering questions about data in tables (top-N, filtering, group comparisons)

  • Data cleaning: missing values, outliers, type conversion, normalization

When NOT to Use

  • The task has no data context (no tables, timetables, arrays, or date/time values to work with)

  • The primary goal is visualization or plotting, not data analysis (use matlab-build-chart instead)

  • The task is purely symbolic math, simulation, or app building

  • Reading or writing files — CSV, Excel, Parquet, MAT-file (use matlab-import-export-data instead)

  • Data doesn't fit in memory or requires out-of-core processing (use matlab-choose-big-data-solution instead)

  • Storing or retrieving passwords, tokens, or API keys (use matlab-secure-credentials instead)

  • Data lives in a relational database (use matlab-use-database or matlab-use-duckdb instead)

  • Building an ML training pipeline from labeled signal files (use matlab-prepare-signal-data instead)

  • Training classifiers or comparing ML model accuracy on tabular data (use matlab-classify-tabular-data instead)

  • Engineering or selecting features to optimize a supervised ML model (use matlab-engineer-tabular-features instead)

  • Code migration or replacing deprecated APIs (use matlab-modernize-code instead)

Routing: Read references on all relevant topics

This skill covers core MATLAB functions for tabular, time-series, and array-based data workflows — including numeric arrays, sensor matrices, and gridded data. These functions work natively with table, timetable, and numeric arrays, handle missing data correctly, and are performance-optimized. Prefer the modern functions recommended here (e.g., groupsummary, datetime, fillmissing, smoothdata2) over legacy alternatives (e.g., accumarray, nanmean, datenum). Override only if the user explicitly requests otherwise.

Each section below links to a reference file. ALWAYS read the reference file for every relevant topic before writing code. Reference files contain correct syntax, common pitfalls, and "Avoid" patterns that prevent silent bugs. Skipping the reference risks using a deprecated approach or hitting a known pitfall. After reading, state Reference files read: [list] at the top of your response.

Key Functions — Available From

Most functions in this skill are available in R2023a or earlier. The following require a newer release:

FunctionAvailable FromPurpose
paddata, trimdata, resizeR2023bPad, trim, or resize arrays to target length
smoothdata2R2023bSmooth 2-D gridded data over rectangular windows
kdeR2023bKernel density estimate for univariate data
clipR2024aClamp values to a range
islocalmax2, islocalmin2R2024aDetect local extrema in 2-D gridded data
summary (enhanced)R2024bSupports arrays (numeric, datetime, duration, logical); adds Statistics, DataVariables, Detail name-value args
isapproxR2024bTolerance-aware floating-point comparison (use instead of == for computed values)
isbetween (numeric)R2024bCheck elements within a numeric range
numuniqueR2025aCount distinct values in a variable
allbetweenR2025aValidate all values are within a range
alluniqueR2025aValidate all values are unique

Getting Oriented with Data

When data is already in a workspace variable, start by understanding its structure and contents before writing analysis code.

Topics:

  • Summarizing structure, shape, and variable types

  • Assessing how much data is missing and where

  • Understanding distributions (numeric quartiles, categorical value counts)

  • Finding correlations and relationships between variables

  • Checking for duplicates, unique keys, and cardinality

  • Exploring time range, regularity, and temporal patterns

Functions: summary, head, size, jsonencode, anymissing, allfinite, ismissing, groupcounts, numunique, allunique, kde, corrcoef, pivot, unique, isregular, isuniform, retime

Read: exploration.md


Data Types

Use modern MATLAB types instead of legacy alternatives. Modern types are faster, more readable, and work better with table functions.

Topics:

  • Dates and times (parsing, arithmetic, timezones, extracting year/month/day/hour)

  • Elapsed time and calendar offsets

  • Text data (comparing, searching, splitting, editing strings)

  • Categorical data (ordinal rankings, merging/renaming/reordering levels)

Functions: datetime, dateshift, year, month, day, weekday, quarter, hour, timeofday, ymd, hms, hours, days, minutes, seconds, calmonths, caldays, string, matches, contains, startsWith, extractAfter, extractBefore, replace, erase, strip, split, count, categorical, mergecats, renamecats, removecats, reordercats, countcats

Read: data-types.md


Tables and Timetables

Tables are the primary container for tabular data. Use timetable when the data has timestamps, a time vector, or a known sample rate — it unlocks time-aware operations (automatic spacing-aware smoothing, filling, and resampling).

Topics:

  • Creating and structuring tables (variables vs rows, metadata, properties)

  • Selecting variables by type; dot indexing vs braces vs parentheses

  • Converting variable types after import

  • Working with non-uniformly spaced data (SamplePoints)

  • Resampling, aligning, and synchronizing time series

  • Filtering by date range or time tolerance

  • Converting legacy timeseries objects

Functions: table, timetable, table2timetable, vartype, convertvars, retime, synchronize, lag, timerange, withtol, timeseries2timetable, table2array, array2table

Read: tables-and-timetables.md


Eventtables

Use eventtable when tagging or annotating timetable rows with events, episodes, or phases (sensor anomalies, storms, maintenance windows, alarms). Do NOT add boolean columns, string labels, or categorical state variables to the timetable itself.

Topics:

  • Creating an eventtable from timestamps and labels (instantaneous or interval)

  • Attaching events to a timetable

  • Filtering timetable rows by event properties

  • Extracting events from patterns in data (peaks, threshold crossings)

  • Pushing event data into timetable rows for export or grouping

  • Automatic event overlays in plots

Functions: eventtable, eventfilter, extractevents, syncevents, withtol, stackedplot

Read: eventtables.md


Data Cleaning

Handle missing values and outliers using MATLAB's built-in detection and fill functions. Never compare with == for missing values. Use standardizeMissing to convert sentinel values before filling or removing.

Topics:

  • Detecting missing values (NaN, NaT, missing strings, undefined categoricals)

  • Converting placeholder values ("N/A", -999, "") to standard missing

  • Filling gaps (interpolation, forward-fill, moving window, per-type strategies)

  • Limiting fill across long gaps

  • Skipping missing values in aggregation (mean, std, min, max) — correct calling syntax

  • Detecting, removing, or replacing outliers

  • Checking whether values fall within an expected range; clamping

Functions: ismissing, anymissing, standardizeMissing, fillmissing, rmmissing, isoutlier, rmoutliers, filloutliers, isbetween, allbetween, clip

Read: data-cleaning.md


Data Transformation

Filter, sort, reshape, normalize, bin, join, and manage table variables. Use vectorized operations and built-in functions — not loops over rows or manual if-else chains.

Topics:

  • Filtering rows by condition or value range

  • Sorting and retrieving top/bottom N rows

  • Applying functions across rows or across variables

  • Renaming, reordering, adding, removing, splitting, merging variables

  • Converting types and applying in-place transforms

  • Binning continuous values into categories

  • Normalizing, scaling, z-scoring

  • Reshaping between wide and tall formats (pivot, stack, unstack)

  • Joining/merging tables on key variables

Functions: sortrows, topkrows, rowfun, varfun, convertvars, renamevars, movevars, addvars, removevars, splitvars, mergevars, discretize, normalize, clip, rescale, isapprox, isbetween, pivot, stack, unstack, rows2vars, innerjoin, outerjoin, join

Read: data-transformation.md


Grouping and Aggregation

groupsummary is the go-to for grouped statistics — not findgroups+accumarray or manual loops. Use groupfilter for per-group row filtering, grouptransform for per-group normalization, and pivot for cross-tabulation.

Topics:

  • Computing statistics by group (mean, sum, std, min, max, custom)

  • Binning on the fly (numeric edges, hourly/monthly/seasonal time bins)

  • Handling missing or empty groups

  • Filtering rows based on group-level conditions (e.g., minimum group size)

  • Removing per-group outliers

  • Normalizing within each group (z-score, rescale)

  • Cross-tabulating counts or aggregated values

Functions: groupsummary, groupcounts, groupfilter, grouptransform, pivot, findgroups

Read: grouping-and-aggregation.md


smoothdata is the unified entry point for smoothing (not smooth, which requires Curve Fitting Toolbox). Use detrend or trenddecomp for trend removal/decomposition, and islocalmax/islocalmin/ischange for pattern detection.

Topics:

  • Smoothing noisy data (moving average, Gaussian, Savitzky-Golay, median)

  • Choosing window size (element count vs duration for time-stamped data)

  • Removing linear or polynomial trends

  • Separating trend from seasonality (seasonal decomposition)

  • Finding peaks, valleys, and local extrema

  • Detecting abrupt changes in mean, variance, or slope

  • Summarizing distributions (bin counts, histograms)

Functions: smoothdata, movmean, movmedian, detrend, trenddecomp, islocalmax, islocalmin, ischange, histcounts, histogram

Read: smoothing-and-trends.md


Array and Grid Data

Use arrays when data is homogeneous numeric AND either naturally 2D/grid, performance-critical, or delivered by upstream tooling. For 2D grids, use dedicated 2D functions — do not loop 1D functions over rows/columns.

Topics:

  • When to stay in arrays vs converting to table

  • Operating along a specific dimension (row-wise vs column-wise)

  • Common pitfalls with dimension arguments in std, var, movstd, movvar

  • Handling NaN in array computations (not automatic)

  • Moving window and cumulative statistics

  • Padding, trimming, or resizing arrays to a target length

  • 2D spatial smoothing, gap filling, and peak detection on grids

  • Grouped operations using a grouping vector

Functions: smoothdata2, fillmissing2, islocalmax2, islocalmin2, paddata, trimdata, resize, mink, maxk, bounds, rms, prctile, quantile, iqr, cumsum, cummax, cummin, cumprod, movmean, movmedian, movsum, movstd, movvar, isuniform, isregular

Read: array-and-grid-data.md


Answering Questions About Data

When the task is answering a specific question about data (top-N, filtering, lookups, comparisons), read the strategies reference to avoid common mistakes with sorting direction, missing data, and value interpretation.

Topics:

  • Finding the highest/lowest/top/bottom N entries

  • Looking up values in one column based on ranking in another

  • Accounting for missing or placeholder values in answers

  • Returning raw data values without substitution or mapping

  • Counting rows that match a condition (exact vs partial text matching)

Functions: topkrows, sortrows, groupsummary, standardizeMissing, isapprox, matches, contains, height, nnz

Read: answering-data-questions.md


Copyright 2026 The MathWorks, Inc.

Files

references/exploration.md

Data Exploration

Contents: first look (head/summary/size), missing data assessment, variable distributions, relationships (corrcoef/pivot), uniqueness/cardinality, duplicates, outlier screening, time-based exploration

Strategies for systematic data exploration: understanding structure, identifying patterns, summarizing distributions, and forming hypotheses before deeper analysis.

General Guidance

  • Explore before transforming. Understand the data before cleaning or reshaping it. Premature cleaning can mask important signals (e.g., removing "outliers" that are actually a meaningful subgroup).

  • Check your assumptions. If a variable is called "Age", verify it contains plausible age values. Sentinel values (-1, 999, 0) are common.

  • Start broad, then narrow. Use summary and groupcounts to get the big picture before drilling into specific rows or subsets.

  • Document what you find. If exploring interactively, note surprises: unexpected missing patterns, outliers, duplicate keys, or variables that don't contain what their name suggests.

  • Add value where AI helps most. Text-heavy tasks like populating VariableDescriptions, VariableUnits, or renaming variables to be more descriptive are a natural fit for AI assistance. Offer to enrich table metadata when it is sparse or missing.

1. First Look

Start with structure and shape before any analysis. Prefer wrapping exploration output with jsonencode — particularly for tables and structs. The default displays are better for human readers, but it is easy for agents to misinterpret which values belong to which variables in plain-text table output. JSON gives unambiguous, structured results:

jsonencode(summary(T))      % per-variable stats as nested struct
jsonencode(head(T))         % first 8 rows as structured JSON

summary has two modes:

  • Display mode (no output captured): prints human-readable stats to the command window.

  • Struct mode (output captured or passed to a function, as in jsonencode(summary(T))): returns a struct whose field names are the variable names. Each field contains Size, Type, and NumMissing, plus type-specific statistics listed below.

Default statistics by variable type:

  • numeric, datetime, duration: Min, Median, Max, Mean, Std

  • categorical (ordinal): Min, Median, Max, plus category counts

  • categorical (non-ordinal): category counts only

  • logical: true/false counts only

  • string, calendarDuration, other: NumMissing only (no additional stats)

This single call already provides variable names, types, dimensions, missing counts, and descriptive statistics — AVOID recomputing these with varfun(@class,...), sum(ismissing(...)), or similar.

For standalone scripts intended for human readers, leave the semicolon off to invoke the display method — it shows dimensions, variable names, and a truncated preview. Avoid disp (omits headers and prints every row, flooding output on large tables) and fprintf in a loop (verbose, old-style):

head(T)                         % first 8 rows - see what the data looks like
summary(T)                      % per-variable: type, stats, missing counts
size(T)                         % [nRows, nVars] -- not necessary if also calling summary()
T.Properties.VariableNames      % variable names -- not necessary if also calling summary()
T.Properties.VariableTypes      % programmatic access to types -- not necessary if also calling summary()
T                               % dimensions + header + truncated preview

summary is the single most informative exploration command. It always includes the basics for every variable: Size, Type, and Description (when available). It also shows a default set of per-variable descriptive statistics (min, median, max for numeric; counts for categorical), and missing value counts. For wide tables it is more useful than head since it shows every variable without truncation. From R2024b, use Statistics, DataVariables, and Detail name-value arguments to customize:

summary(T, Statistics=["mean" "std" "min" "max"], DataVariables=vartype("numeric"))  % R2024b+
summary(T, Statistics="allstats")    % everything available; silently skips stats that don't apply to a given type
summary(T, Detail="high")            % show all metadata (descriptions, units, category counts)

Note: Detail="high" only affects the printed display. When capturing output (s = summary(T)), the returned struct always includes all metadata regardless of Detail.

2. Missing Data Assessment

If you already called summary(T), each variable's struct field includes NumMissing — you do not need sum(ismissing(T)) to repeat that count. Use the functions below for targeted missing-data questions if the full summary(T) has not been already calculated:

anymissing(T)                               % quick check: any missing values at all?
allfinite(T)                                % quick check: all values finite? (catches NaN and Inf)
sum(ismissing(T))                           % missing count per variable
sum(ismissing(T)) ./ height(T) * 100        % missing percentage per variable
T.Properties.VariableNames(sum(ismissing(T)) > 0)  % which variables have any missing

Look for patterns: is missingness concentrated in a few variables, or scattered? Are rows with missing values in one variable also missing in others? This informs whether to fill, drop, or ignore.

% Variables with >50% missing — candidates for dropping
pctMissing = sum(ismissing(T)) ./ height(T) * 100;
T.Properties.VariableNames(pctMissing > 50)

3. Variable Distributions

Summarize differently depending on type:

Numeric variables:

% Or per-variable
[min(T.Age) median(T.Age) max(T.Age) std(T.Age)]
prctile(T.Price,[25 50 75])         % quartiles

Categorical/string variables:

groupcounts(T,"Status")                     % value counts with percentages
numunique(T.City)                           % number of distinct values (R2025a+)
countcats(T.Category)                       % counts for each defined category
categories(T.Category)                      % list defined category names
Density estimation

Use kde (base MATLAB, R2023b) for smooth univariate density estimates:

% Basic density estimate
[f, xf, bw] = kde(T.Price);

% Positive data with plug-in bandwidth — good for multimodal or skewed distributions
% Support: "unbounded" (default), "positive", "nonnegative", "negative", or [L U]
% Bandwidth: "normal-approx" (default), "plug-in", or positive scalar
[f, xf] = kde(T.ResponseTime, Support="positive", Bandwidth="plug-in");

% Cumulative distribution function
% ProbabilityFcn: "pdf" (default) or "cdf"
[f, xf] = kde(T.Value, ProbabilityFcn="cdf", Support=[0 100]);

Also accepts Kernel ("normal", "box", "triangle", "parabolic", or function handle), EvaluationPoints or NumPoints to control where the estimate is evaluated, and Weight for weighted observations.

For bivariate density, censored data, or survival functions ("survivor", "cumhazard", "icdf"), use ksdensity (requires Statistics and Machine Learning Toolbox).

4. Relationships Between Variables

These are examples of common techniques, not an exhaustive list. Choose what is appropriate for the data and question — consider other approaches beyond these based on the dataset's characteristics:

% Pearson correlation (corrcoef is base MATLAB)
% Use Rows="complete" to drop rows with any NaN (default propagates NaN)
R = corrcoef(T{:,vartype("numeric")}, Rows="complete");

% Cross-tabulation of two categorical variables
pivot(T, Rows="Department", Columns="Status", Method="count")

% Group means - does a numeric variable differ across groups?
groupsummary(T,"Region","mean","Revenue")

For Kendall or Spearman rank correlation, use corr (requires Statistics and Machine Learning Toolbox) with the Type name-value argument. When complete cases are required and you need to explicitly remove rows, see the rmmissing caution in data-cleaning.md.

5. Uniqueness and Cardinality

Understanding cardinality helps decide how to use a variable (group by it? filter on it? ignore it?):

% Unique value counts for all variables at once
summary(T, Statistics="numunique")

% Check if a variable could serve as an ID (all unique, no missing)
allunique(T.ID) && ~anymissing(T.ID)       % allunique: R2025a+

6. Duplicates

% Find duplicate rows (all variables)
[~,idx] = unique(T,"rows","stable");
dupIdx = setdiff(1:height(T),idx);
T(dupIdx, :)                                % inspect duplicate rows

% Duplicates in a key variable
[~,ia] = unique(T.CustomerID,"stable");
dupKeys = T.CustomerID(setdiff(1:height(T),ia));
T(ismember(T.CustomerID,dupKeys), :)        % all rows with duplicated keys

7. Outlier Screening

Use isoutlier for quick detection:

isoutlier(T.Price)                          % default: median + 3 scaled MAD
isoutlier(T.Price,"quartiles")              % IQR-based (1.5x IQR beyond Q1/Q3)
isoutlier(T.Price,"grubbs")                % Grubbs' test (assumes normality)
isoutlier(T.Price,"movmedian",20)          % sliding window (good for time series with drift)

% Per-group outlier detection (via groupfilter)
T = groupfilter(T,"Department",@(x) ~isoutlier(x),"Salary");

See data-cleaning.md for handling outliers after detection.

8. Time-Based Exploration

For timetables or tables with datetime variables:

[min(TT.Time) max(TT.Time)]                % date range
TT.Time(end) - TT.Time(1)                  % total span

% Check regularity and get step size
[tf,step] = isregular(TT);                 % timetables, datetime, and duration arrays
[tf,step] = isuniform(x);                  % numeric arrays

issorted(TT.Time,"strictascend")            % check for monotonically increasing timestamps

% Quick resample to see trends
daily = retime(TT,"daily","mean");
monthly = retime(TT,"monthly","mean");

Copyright 2026 The MathWorks, Inc.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs an API key

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
MathWorks
Publisher
MathWorks (Official)
Source
matlab/matlab-agentic-toolkit · skills-catalog/matlab-data-import-and-analysis/matlab-analyze-data · commit 2a7f215
Licence
BSD 2-Clause License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE.md)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by MathWorks or MathWorks.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download matlab-analyze-data.zip