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
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-Files Preferences:
On the Home tab, in the Environment section, click Preferences.
Select MATLAB > General > MAT-Files.
The preferences apply to both the
and the Save 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 ||Preference Option|
|Version 7.3||R2006b (Version 7.3) or later|
Saving and loading parts of variables, and all Version 7 features
|Yes||≥ 2 GB on 64-bit computers||MATLAB Version 7.3 or later|
|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||2^31 bytes per variable||MATLAB Version 7 or later|
|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||MATLAB Version 5 or later|
|No||100,000,000 elements per array, and 2^31 bytes per variable||n/a|
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 a MAT-file version other than the default version when you want to:
Allow access to the file using earlier versions of MATLAB.
Take advantage of Version 7.3 MAT-file features.
Reduce the time required to load and save some files by storing uncompressed data.
Reduce the size of some files by storing compressed data.
To save to a MAT-file version other than the default version,
version as the last input to the
For example, to create a Version 6 MAT-file named
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:
The amount of data in each item is small relative to the complexity of its container. For example, simple numeric arrays take less time to compress and uncompress than cell or structure arrays of the same size. Compressing arrays that result in an uncompressed file size of less than 3 MB offers limited benefit, unless you are transferring data over a network.
The data is random, with no repeated patterns or consistent values.
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.