MAT-files are binary MATLAB® files that store workspace
variables. By default, all save operations except new file creation
matfile function create Version 7 MAT-files.
When you create new MAT-files using the
the default MAT-file version is 7.3.
The maximum size of a MAT-file is imposed only by your native file system.
To identify or change the default MAT-file version,
access the MAT-Files Preferences: On the Home tab,
in the Environment section, click
Select MATLAB > General > MAT-Files. The preferences
apply to both the
save function and the Save menu
This table lists and compares all MAT-file versions.
|Version||Loads in MATLAB Versions||Supported Features||Compression||Maximum Size of Each Variable||Value of ||Preference Option|
|Version 7.3||7.3 (R2006b) 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||7.0 (R14) 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||5 (R8) 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|
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 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,
specify a value of
version as the last input argument
save function. 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 fact, loading compressed data is sometimes 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.
However, 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.