MAT-File Format - SERC
MAT-File Format - SERC MAT-File Format - SERC
1 MAT-File FormatIntroductionThis document describes the internal format of MATLAB ® Level 4 and Level 5MAT-files. Level 4 MAT-files are compatible with versions of MATLAB up toVersion 4. Level 5 MAT-files are compatible with MATLAB Versions 5 and up.You can read and write Level 4 MAT-files with the later versions of MATLAB,but when writing a MAT-file under these circumstances, you need to specify aswitch in the save or matOpen command line to tell MATLAB that the MAT-fileis at Level 4.A MAT-file stores data in binary (not human-readable) form. In MATLAB, youcreate MAT-files using the save function, which writes the arrays currently inmemory to a file as a continuous byte stream. By convention, this file has thefilename extension .mat; thus the name MAT-file. The load function reads thearrays from a MAT-file into the MATLAB workspace.Most MATLAB users do not need to know the internal format of a MAT-file.Even users who must read and write MAT-files from C and Fortran programsdo not need to know the MAT-file format if they use the MAT-file interface.This interface shields users from dependence on the details of the MAT-fileformat.Note See “Importing and Exporting Data” in the MATLAB ExternalInterfaces documentation for information on the MAT-file interface. See “C [orFortran] MAT-File Functions” in the MATLAB External Interfaces Referencedocumentation for information on the functions available with this interface.However, if you need to read or write MAT-files on a system that does notsupport the MAT-file interface, you must write your own read and writeroutines. The MAT-file interface is only available for platforms on whichMATLAB is supported. This document provides the details about the MAT-fileformat you will need to read and write MAT-files on these systems.1-2
IntroductionNote Whenever possible, The MathWorks strongly advises you to use theMAT-file interface functions to read and write MAT-files. Any code you writethat depends on the MAT-file format may need to be rewritten when theformat changes in future releases.MAT-File FormatsThis document describes both Level 5 and Level 4 MAT-file formats. The Level5 MAT-file format supports all the array types supported in MATLAB versions5 and up, including multidimensional numeric arrays, character arrays, sparsearrays, cell arrays, structures, and objects. “Level 5 MAT-File Format” onpage 1-4 describes this format.The Level 4 MAT-file format is a simpler format but it only supportstwo-dimensional matrices and character strings. “Level 4 MAT-File Format”on page 1-36 describes this format.1-3
- Page 1 and 2: MATLAB®The Language of Technical C
- Page 3: Revision History:June 1999 Online o
- Page 8 and 9: 1 MAT-File FormatLevel 5 MAT-File F
- Page 10 and 11: 1 MAT-File FormatMAT-File Header Fo
- Page 12 and 13: 1 MAT-File FormatData Element Forma
- Page 14 and 15: 1 MAT-File FormatFor character data
- Page 17 and 18: Level 5 MAT-File FormatEach variabl
- Page 19 and 20: Level 5 MATLAB Array Data Element F
- Page 21 and 22: Level 5 MATLAB Array Data Element F
- Page 23 and 24: Level 5 MATLAB Array Data Element F
- Page 25 and 26: Level 5 MATLAB Array Data Element F
- Page 27 and 28: Level 5 MATLAB Array Data Element F
- Page 29: Level 5 MATLAB Array Data Element F
- Page 32 and 33: 1 MAT-File Formatsee “Numeric Arr
- Page 34 and 35: 1 MAT-File FormatDimensions Array S
- Page 36 and 37: 1 MAT-File FormatFigure 1-14: Examp
- Page 38 and 39: 1 MAT-File FormatClass. This field
- Page 40 and 41: 1 MAT-File FormatLevel 4 MAT-File F
- Page 42 and 43: 1 MAT-File FormatTable 1-8: Level 4
- Page 44 and 45: 1 MAT-File FormatAgain, we strongly
- Page 46 and 47: IndexHheaderdefined 1-4flag fields
- Page 48: IndexIndex-4
IntroductionNote Whenever possible, The MathWorks strongly advises you to use the<strong>MAT</strong>-file interface functions to read and write <strong>MAT</strong>-files. Any code you writethat depends on the <strong>MAT</strong>-file format may need to be rewritten when theformat changes in future releases.<strong>MAT</strong>-<strong>File</strong> <strong>Format</strong>sThis document describes both Level 5 and Level 4 <strong>MAT</strong>-file formats. The Level5 <strong>MAT</strong>-file format supports all the array types supported in <strong>MAT</strong>LAB versions5 and up, including multidimensional numeric arrays, character arrays, sparsearrays, cell arrays, structures, and objects. “Level 5 <strong>MAT</strong>-<strong>File</strong> <strong>Format</strong>” onpage 1-4 describes this format.The Level 4 <strong>MAT</strong>-file format is a simpler format but it only supportstwo-dimensional matrices and character strings. “Level 4 <strong>MAT</strong>-<strong>File</strong> <strong>Format</strong>”on page 1-36 describes this format.1-3