MAT-File Versions - MATLAB & Simulink (original) (raw)

Main Content

Overview of MAT-File Versions

MAT-files are binary MATLAB® files that store workspace variables. Starting with MAT-file Version 4, there are several subsequent versions of MAT-files that support an increasing set of features. MATLAB releases R2006b and later all support all MAT-file versions.

By default, all save operations create Version 7 MAT-files. The only exception to this is when you create new MAT-files using the matfile function. In this case, the default MAT-file version is 7.3.

To identify or change the default MAT-file version, access the MAT and FIG Files settings.

The settings apply to both the save function and the menu options.

The maximum size of a MAT-file is imposed only by your native file system.

This table lists and compares all MAT-file versions.

MAT-File Version Supported MATLAB Releases Supported Features Compression Maximum Size of Each Variable Value of version argument in save function Setting Option
Version 7.3 R2006b (Version 7.3) or later Saving and loading parts of variables, and all Version 7 features Yes (default) ≥ 2 GB on 64-bit computers '-v7.3' MATLAB Version 7.3 or later(save -v7.3)
Version 7 R14 (Version 7.0) or later Unicode® character encoding, which enables file sharing between systems that use different default character encoding schemes, and all Version 6 features. Yes (default) 2^31 bytes per variable '-v7' MATLAB Version 7 or later(save -v7)
Version 6 R8 (Version 5) or later N-dimensional arrays, cell arrays, structure arrays, variable names longer than 19 characters, and all Version 4 features. No 2^31 bytes per variable '-v6' MATLAB Version 5 or later(save -v6)
Version 4 All Two-dimensional double, character, and sparse arrays No 100,000,000 elements per array, and 2^31 bytes per variable '-v4' n/a

Note

Version 7.3 MAT-files use an HDF5 based format that requires some overhead storage to describe the contents of the file. For cell arrays, structure arrays, or other containers that can store heterogeneous data types, Version 7.3 MAT-files are sometimes larger than Version 7 MAT-files.

Save to Nondefault MAT-File Version

Save to a MAT-file version other than the default version when you want to:

To save to a MAT-file version other than the default version, specify a version as the last input to the save function. For example, to create a Version 6 MAT-file named myfile.mat, type:

Data Compression

Beginning with Version 7, MATLAB compresses data when writing to MAT-files to save storage space. Data compression and decompression slow down all save operations and some load operations. In most cases, the reduction in file size is worth the additional time spent.

In some cases, loading compressed data actually can be faster than loading uncompressed data. For example, consider a block of data in a numeric array saved to both a 10 MB compressed file and a 100 MB uncompressed file. Loading the first 10 MB takes the same amount of time for each file. Loading the remaining 90 MB from the uncompressed file takes nine times as long as loading the first 10 MB. Completing the load of the compressed file requires only the relatively short time to decompress the data.

The benefits of data compression are negligible in the following cases:

Accelerate Save and Load Operations for Version 7.3 MAT-Files

Version 7.3 MAT-files use an HDF5-based format that stores data in compressed chunks. The time required to load part of a variable from a Version 7.3 MAT-file depends on how that data is stored across one or more chunks. Each chunk that contains any portion of the data you want to load must be fully uncompressed to access the data. Rechunking your data can improve the performance of the load operation. To rechunk data, use the HDF5 command-line tools, which are part of the HDF5 distribution.

See Also

save | matfile

Topics