viewhack

Open a MATLAB .mat file without MATLAB, and save its variables as CSV

Drop a .mat file a supervisor, a dataset page or a lab instrument gave you. See every variable in it with its class, size and bytes, open a matrix as a table, read text, walk through structs and cell arrays, and save any matrix as CSV for Excel, R or Python, or the whole file as JSON.

The file is read by this tab on your device. It is not uploaded, so unpublished data stays yours.

What it shows

Saving as CSV and JSON

The formats, and what this reads in each

v7 (MATLAB's default)
What save writes unless told otherwise: a Level 5 file in which each variable is zlib-compressed on its own (the miCOMPRESSED data type). It is unpacked here with the bundled fflate library. Files from GNU Octave (save -v7) and SciPy (savemat(..., do_compression=True)) are the same format.
v6 and v5
The same Level 5 layout without compression: save -v6, MATLAB 5 to 6.5, and scipy.io.savemat by default. Little-endian (IM) and big-endian (MI, from old Sun and Mac machines) files both open.
Level 4
MATLAB 4's format, still written by save -v4, Octave, SciPy (format='4') and some instruments: a 20-byte header per matrix and its values, no compression, numeric and text matrices only (and sparse ones as a list of triplets). A Level 4 file has no signature, so outside this page viewhack only recognises it when its name ends in .mat.
v7.3
An HDF5 file behind a 512-byte MAT-file header, written by save -v7.3 and needed for variables over 2 GB. This page recognises it and says so, but cannot read it yet. Re-save it in MATLAB with S = load('data.mat'); save('data_v7.mat', '-struct', 'S', '-v7'); GNU Octave can usually load a v7.3 file of plain arrays and save it the same way.

What this cannot do

Opening the CSV elsewhere

Excel or LibreOffice
Open the .csv directly. The values have no header row, just as the matrix has no column names; row 1 of the sheet is row 1 of the matrix.
Python
numpy.loadtxt('A.csv', delimiter=',') gives back the same matrix. NaN and Inf read correctly; complex values (written 1+2i) need MATLAB's i changed to Python's j first.
R
as.matrix(read.csv('A.csv', header = FALSE)).

MATLAB is a trademark of The MathWorks, Inc. viewhack is not affiliated with The MathWorks; this reader was written from the MAT-file format description MathWorks publishes.