Skip to main content

MATLAB MAT Format

Read MATLAB .mat variables as one record per array row (or element for 1D arrays).

Overview

PropertyValue
Format idmat (alias matlab)
ClassMATIterable
Extensions.mat
ReadYes
WriteNo
Extramat (scipy / numpy; v7.3 also needs h5py)
Maturityexperimental

Record shape

Array rankRecord
1D{"value": scalar} per element
2D{"col0": ..., "col1": ..., ...} per row
0D{"value": scalar}

Only 1D/2D arrays are iterated. Use list_tables() for variable names. When multiple variables exist, pass variable or table.

Parameters

ParameterDescription
variable / tableMAT variable name (required when multiple variables)

Requires a filename path.

Usage

from iterable import open_iterable

with open_iterable("data.mat", format="mat", iterableargs={"variable": "data"}) as source:
for row in source:
print(row) # e.g. {"col0": 1.0, "col1": 2.0}

Install with pip install iterabledata[mat].

See also