Skip to content

Sample MATLAB .mat files to download

Nine small and large .mat files of invented UK weather, for checking that a MAT reader, converter or plotting script gets each format right. They cover versions 4, 6, 7 and 7.3, nested structs and cells, and two kinds of Simulink output. Each one is a single download, free under CC0, with nothing to sign up for.

The nine files

Download saves the file as it is. Open in the plotter loads it into the MegaRows plotter in this browser, without saving a copy first.

uk-weather-v4.mat

Version 4 · 173 KB · 4,320 rows

Inside:
Time in seconds and four weather signals, 4,320 rows each, and Start_Time as text.
Good for testing:
The oldest reader path: no text header at all, and this file holds only two-dimensional double and char arrays.

uk-weather-v6.mat

Version 6, uncompressed · 173 KB · 4,320 rows

Inside:
The same variables and values as the version 4 file, saved without compression.
Good for testing:
Level 5 tags and padding with no zlib in the way, so each byte can be traced by hand.

uk-weather-v7.mat

Version 7, compressed · 30.6 KB · 4,320 rows

Inside:
The same variables and values again, each one compressed.
Good for testing:
zlib inflation in the format a plain save writes, at under a fifth of the version 6 size.

uk-weather-v73.mat

Version 7.3 · 177 KB · 4,320 rows

Inside:
The same variables and values in the HDF5-based layout.
Good for testing:
The HDF5 route: the MATLAB block in front, MATLAB_class attributes and arrays stored transposed.

uk-weather-v73-1m-rows.mat

Version 7.3 · 4.33 MB · 1,000,000 rows

Inside:
The same six variables at one row a second: 1,000,000 rows in compressed chunks.
Good for testing:
Open time and memory use, and reads of deflate-compressed chunks of 8,192 values.

uk-weather-struct-cell-v7.mat

Version 7 · 20.0 KB · 2,160 hourly readings; 4 × 365 daily values

Inside:
A weather station struct with 2,160 hourly readings, a 1×4 struct array, cell arrays, a char matrix and logicals.
Good for testing:
Fields inside fields, a struct array, cells of text and of vectors, a char matrix and true/false values.

uk-weather-struct-cell-v73.mat

Version 7.3 · 118 KB · 2,160 hourly readings; 4 × 365 daily values

Inside:
The same structs and cells saved as version 7.3, the cells as references.
Good for testing:
HDF5 groups with a MATLAB_fields list, and cells held as references into the #refs# group.

uk-weather-simulink-to-workspace-v7.mat

Version 7 · 99.2 KB · 3,001 rows

Inside:
tout and yout (3,001 rows of three signals) and simout in the Structure With Time format.
Good for testing:
Two of the layouts a To Workspace block saves: plain arrays beside tout, and a struct with its own time.

uk-weather-simulink-simulationoutput-v7.mat

Version 7, saved by MATLAB · 52.3 KB · 601, 121 and 61 rows (three rates)

Inside:
One variable, out: a SimulationOutput with logged signals at three rates, a bus and To Workspace outputs.
Good for testing:
A MATLAB object rather than plain arrays: logged Datasets, a bus and timeseries.

Which file to pick for a test

The sample file to use for each kind of test
To checkUse
A reader that claims every versionuk-weather-v4.mat, uk-weather-v6.mat, uk-weather-v7.mat, uk-weather-v73.mat
Decompression of version 7 datauk-weather-v7.mat
Reading version 7.3 through HDF5uk-weather-v73.mat
Speed and memory on a large fileuk-weather-v73-1m-rows.mat
Nested structs, cells and logicalsuk-weather-struct-cell-v7.mat, uk-weather-struct-cell-v73.mat
Simulink To Workspace outputuk-weather-simulink-to-workspace-v7.mat
A Simulink SimulationOutput objectuk-weather-simulink-simulationoutput-v7.mat

The four version files carry identical numbers, so whatever a reader returns for one of them it should return for the other three. A difference between them points at the reader, not the data.

What the variables hold

Every value is invented. The names follow UK cities so that a plot reads naturally, and the units below are the ones the generator used; the files themselves carry no unit labels.

  • The four version files hold Time (seconds since Start_Time), London_Temperature (°C), Manchester_Wind_Speed (m/s), Edinburgh_Rainfall (mm/h) and Cardiff_Pressure (hPa), each a 4,320 × 1 column of doubles: 30 days at one row every 10 minutes. Start_Time is the text 2026-01-01T00:00:00Z.
  • The 1,000,000-row file has the same six names with one row a second, from 0 to 999,999 s (about 11.6 days), and its own values.
  • The struct and cell files hold Met_Station, a struct for London with a nested Readings struct of 2,160 hourly Time, Temperature (°C), Relative_Humidity (%) and Wind_Speed (m/s) values; Stations, a 1 × 4 struct array whose Is_Coastal field is a logical; Station_Names, a 1 × 4 cell of text; Station_Codes, a 4 × 3 char matrix; Day_Of_Year, a 365 × 1 vector; Daily_Temperature, a 1 × 4 cell of 365 values per station; Station_Table, a 5 × 3 cell with a header row; and Notes, one line of text.
  • The To Workspace file holds tout, 0 to 300 s in steps of 0.1 s; yout, 3,001 rows of London temperature, Leeds humidity and York pressure; and simout with time, signals.values (Bristol temperature and wind speed) and blockName.
  • The SimulationOutput file holds one variable, out, from a 60-second run: logged London temperature every 0.1 s, Leeds humidity every 0.5 s and York pressure every second, a bus of two signals, the model’s outputs and To Workspace variables in the Array, Structure, Structure With Time and Timeseries formats.

How the versions differ, in short

  • Version 4 starts straight away with its first variable: there is no text header, and only two-dimensional double, char and sparse arrays fit.
  • Version 6 opens with a 128-byte header whose text begins MATLAB 5.0 MAT-file, and stores data uncompressed. It added structs and cells.
  • Version 7 keeps that header and layout and compresses every variable with zlib.
  • Version 7.3 puts a 512-byte block beginning MATLAB 7.3 MAT-file in front of an HDF5 file. Arrays are stored transposed, so a 4,320 × 1 column reads as shape (1, 4320) in h5py.

The releases, size limits and defaults behind each version are covered in what a .mat file is and how its versions compare.

Check a reader against the CSV twins

The repository keeps CSV copies of the data in its csv folder. The generated files’ numbers are written so that each reads back as the very same double; the SimulationOutput signals were written by MATLAB to 15 significant digits. Export a file with the reader under test, compare the result with the matching CSV, and any mismatch shows up in a diff. The repository’s verify.py runs that comparison with SciPy and h5py, and SHA256SUMS confirms a download is complete.

Load a file in MATLAB, Octave or Python

Each snippet expects the file in the current folder; the comments show what it printed when it was run.

MATLAB

whos -file uk-weather-v6.mat
S = load('uk-weather-v6.mat');
S.London_Temperature(1:3)'   % 2.8000   2.9000   2.6000
S.Start_Time                 % 2026-01-01T00:00:00Z

With the version 4, 7 or 7.3 file named instead, the same lines list the same six variables and print the same three temperatures.

GNU Octave

S = load('uk-weather-struct-cell-v7.mat');
S.Stations(3).Name                        % Edinburgh
S.Met_Station.Readings.Wind_Speed(1:3)'   % 4.4000   5.0000   5.7000

Octave 8.4.0 loads all nine files. With the struct and cell file in version 7.3 it warns that it cannot read the cells and the fields of the struct array, and leaves them out.

Python with SciPy: versions 4 to 7

from scipy.io import loadmat

m = loadmat("uk-weather-v4.mat", squeeze_me=True)
print(m["Manchester_Wind_Speed"][:3], m["Start_Time"])
# [2.7 2.7 1.4] 2026-01-01T00:00:00Z

simplify_cells=True turns structs into dictionaries, which suits the Simulink To Workspace file:

from scipy.io import loadmat

m = loadmat("uk-weather-simulink-to-workspace-v7.mat", simplify_cells=True)
print(m["yout"].shape, m["simout"]["blockName"])
# (3001, 3) uk_weather_model/To Workspace

Python with h5py: version 7.3

import h5py

with h5py.File("uk-weather-v73.mat", "r") as f:
    print(list(f.keys()))
    print(f["Edinburgh_Rainfall"].shape, f["Cardiff_Pressure"][0, :3])
# ['Cardiff_Pressure', 'Edinburgh_Rainfall', 'London_Temperature', 'Manchester_Wind_Speed', 'Start_Time', 'Time']
# (1, 4320) [1021.9 1021.8 1021.9]

The snippets ran in GNU Octave 8.4.0 (the MATLAB lines too, which share its syntax) and in Python 3.12 with SciPy 1.14.1 and h5py 3.12.1.

Open one without MATLAB

A downloaded file opens in the MAT file viewer, which lists its variables and plots them in the browser; the file is read on the device and never uploaded. MAT to CSV saves chosen signals as a CSV for a spreadsheet or another program. Made-up data in other formats, from CSV to Parquet, is on the sample files page.

Licence and source

  • Free for any use under CC0 1.0: no permission or credit needed.
  • Synthetic throughout: no observation from a real weather station, and no personal data.
  • Copied byte for byte from the sample-mat-files repository on GitHub (release v1.0), which also holds generate.py, the script that rebuilds eight of the files. The SimulationOutput file was saved by MATLAB with Simulink and is kept as saved.

Frequently asked questions

Are these real weather measurements?

No. A script and a small Simulink model made every value up; only the variable names borrow UK places. No reading in them comes from a weather station, and they hold no personal data.

May I put these files in my own project, course or test suite?

Yes. They are dedicated to the public domain under CC0 1.0: copy, change and ship them, commercially too, with no credit asked for.

Why does scipy.io.loadmat fail on the version 7.3 files?

SciPy reads versions 4 to 7 only. On a 7.3 file it raises NotImplementedError and points to h5py, because a version 7.3 file is an HDF5 file behind a 512-byte MATLAB block. h5py reads it, as the snippet on this page shows.

Can I look inside a .mat file without MATLAB?

Yes. The MAT file viewer opens versions 4 to 7.3 in a browser, lists the variables and plots them; the file stays on the device. Its page lists the MATLAB objects it does not read yet.

Is there a CSV copy of each file to compare a reader with?

Yes, in the csv folder of the repository: one CSV for the four version files, a gzip-compressed one for the 1,000,000-row file, and a CSV per table or signal for the struct and Simulink files.

Why is the version 7 file so much smaller than version 6?

Version 7 compresses each variable with zlib as it saves. The weather signals take 173,392 bytes uncompressed in version 6 and 30,636 bytes in version 7, with the same numbers inside.