Example: barber

MATLAB 7 MAT-File Format - University of Kansas

MATLAB 7 MAT-File FormatHow to Contact enhancement error status, license renewals, pricing, and general information508-647-7000 (Phone)508-647-7001 (Fax)The MathWorks, Apple Hill DriveNatick, MA 01760-2098 For contact information about worldwide offices, see the MathWorks Web Format COPYRIGHT 1999 2011 by The MathWorks, software described in this document is furnished under a license agreement. The software may be usedor copied only under the terms of the license agreement. No part of this manual may be photocopied orreproduced in any form without prior written consent from The MathWorks, ACQUISITION: This provision applies to all acquisitions of the Program and Documentationby, for, or through the federal government of the United States.

MATLAB, but when writing a MAT-file under these circumstances, you need to specify a switch in the save or matOpen command line to tell MATLAB that theMAT-fileisatLevel4. A MAT-file stores data in binary (not human-readable) form. In MATLAB, you create MAT-files using the save function, which writes the arrays

Tags:

  Using, Life, Matlab, Mat file

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of MATLAB 7 MAT-File Format - University of Kansas

1 MATLAB 7 MAT-File FormatHow to Contact enhancement error status, license renewals, pricing, and general information508-647-7000 (Phone)508-647-7001 (Fax)The MathWorks, Apple Hill DriveNatick, MA 01760-2098 For contact information about worldwide offices, see the MathWorks Web Format COPYRIGHT 1999 2011 by The MathWorks, software described in this document is furnished under a license agreement. The software may be usedor copied only under the terms of the license agreement. No part of this manual may be photocopied orreproduced in any form without prior written consent from The MathWorks, ACQUISITION: This provision applies to all acquisitions of the Program and Documentationby, for, or through the federal government of the United States.

2 By accepting delivery of the Programor Documentation, the government hereby agrees that this software or documentation qualifies ascommercial computer software or commercial computer software documentation as such terms are usedor defined in FAR , DFARS Part , and DFARS Accordingly, the terms andconditions of this Agreement and only those rights specified in this Agreement, shall pertain to and governtheuse,modification,reproduction,r elease,performance,display,anddisclosure oftheProgramandDocumentation by the federal government (or other entity acquiring for or through the federal government)and shall supersede any conflicting contractual terms or conditions. If this License fails to meet thegovernment s needs or is inconsistent in any respect with federal procurement law, the government agreesto return the Program and Documentation, unused, to The MathWorks, and Simulink are registered trademarks of The MathWorks, Inc.

3 A list of additional trademarks. Other product or brandnames may be trademarks or registered trademarks of their respective products are protected by one or more patents. Please more HistoryJune 1999 Online onlyNew for MATLAB (Release 11)November 2000 PDF onlyRevised for MATLAB (Release 12)June 2001 PDF onlyRevised for MATLAB (Release )July 2002 PDF onlyRevised for MATLAB (Release 13)January 2003 PDF onlyRevised for MATLAB (Release 13 SP1)June 2004 PDF onlyRevised for MATLAB (Release 14)October 2004 PDF onlyRevised for MATLAB (Release 14SP1)September 2005 PDF onlyMinor revision for MATLAB (Release 14SP3)September 2007 PDF onlyRereleased for Version (Release 2007b)March 2008 PDF onlyRevised for Version (Release 2008a)October 2008 PDF onlyRereleased for Version (Release 2008b)

4 March 2009 PDF onlyRereleased for Version (Release 2009a)September 2009 PDF onlyRereleased for Version (Release 2009b)March 2010 PDF onlyRereleased for Version (Release 2010a)September 2010 PDF onlyRereleased for Version (Release 2010b)April 2011 PDF onlyRereleased for Version (Release 2011a)1 MAT-File FormatIntroduction (p. 1-2)Describes Level 5 and Level 4 MAT-files and how to access 5 MAT-File Format (p. 1-4)Describes the internal Format ofMAT-files that are compatible withMATLAB Versions 5 and 5 MATLAB Array DataElement Formats (p. 1-13)Shows how to use the Array datatype to represent all types ofMATLAB 4 MAT-File Format (p. 1-36)Describes the internal Format ofMAT-files that are compatible withMATLAB Versions 4 and FormatIntroductionThis document describes the internal Format of MATLAB Level 4 and Level 5 MAT-files.

5 Level 4 MAT-files are compatible with versions of MATLAB upto Version 4. Level 5 MAT-files are compatible with MATLAB Versions 5and up. You can read and write Level 4 MAT-files with the later versions ofMATLAB, but when writing a MAT-File under these circumstances, you needto specify a switch in thesaveormatOpencommand line to tell MATLAB MAT-File stores data in binary (not human-readable) form. In MATLAB ,you create MAT-files using thesavefunction, which writes the arrayscurrently in memory to a file as a continuous byte stream. By convention,this file has the filename ; reads the arrays from a MAT-File into the MATLAB MATLAB users do not need to know the internal Format of a 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 shields users from dependence on the details of the "Importing and Exporting Data" in the MATLAB ExternalInterfaces documentation for information on the MAT-File interface.

6 See "C [orFortran] MAT-File Functions" in the MATLAB External Interfaces Referencedocumentation for information on the functions available with this ,ifyouneedtoreadorwriteMAT-filesonasyste mthatdoesnot support the MAT-File interface, you must write your own read MATLAB is supported. This document provides the details about theMAT-file Format you will need to read and write MAT-files on these possible, 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 FormatsThis document describes both Level5 and Level 4 MAT-File formats.

7 TheLevel 5 MAT-File Format supports all the array types supported in MATLABV ersions 5 and up, including multidimensional numeric arrays, characterarrays, sparse arrays, cell arrays, structures, and objects. Level 5 MAT-FileFormat on page 1-4 describes this 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 FormatLevel 5 MAT-File FormatLevel 5 MAT-files are made up of a 128-byteheaderfollowed by one or moredata elements. Each data element is composed of an 8-bytetagfollowed by thedata in the element. The tag specifies the number of bytes in the data elementand how these bytes should be interpreted; that is, should the bytes be readas 16-bit values, 32-bit values, floating-point values or some other data using tags, the Level 5 MAT-File Format provides quick access to individualdata elements within a a tag, and then skipping ahead the specified number of bytes untilthe next Level 5 MAT-File Format on page 1-5 graphically illustrates thisMAT-file Format .

8 The sections that follow provide more details about theseMAT-file elements: MAT-File Header Format on page 1-6 Data Element Format on page 1-7 Data Compression on page 1-111-4 Level 5 MAT-File Format1 Bytes2345678 Data (variable size) or subelementsRepeat tagged data elements until end-of-filesubsys data offsetsubsys data offsetdata typenumber of bytesversionendian indicatorDataelementData (variable size) or subelementsDescriptive text (116 bytes)data typenumber of bytesDataelementMAT-file header (128 bytes)Figure 1-1: MATLAB Level 5 MAT-File Format1-51 MAT-File FormatMAT-File HeaderFormatLevel 5 MAT-files begin with a 128-byte header made up of a 124-byte textfield and two, 16-bit flag section covers the following topics: Header Text Field on page 1-6 Header Subsystem Data Offset Field on page 1-7 Header FlagFields on page 1-7 Header Text FieldThe first 116 bytes of the header can contain text data in human-readableform.

9 Thistext typically provides information that describes how theMAT-file was created. For example, MAT-files created by MATLAB includethe following information in their headers: Level of the MAT-File (value equals1for Level 5) Platformon which the file was created Date andtimethefilewascreatedYou can view the text in a MAT-File header using thecatcommand on UNIX systems, or thetypecommand on a PC. The output displays the text in thispart ofthe header. (The display of the header is followed by unreadablecharacters representing the binary data in the file.)cat MAT-File , Platform: SOL2, Created on: Thu Nov 1310:10:27 1997 NoteWhen creating a MAT-File , youmustwrite data in the first 4 bytes ofthisheader.

10 MATLAB uses these bytes to determine if a MAT-File uses aLevel 5 Format or a Level 4 Format . If any of these bytes contains a zero, MATLAB will incorrectly assume the file is a Level 4 5 MAT-File FormatHeader Subsystem Data Offset FieldBytes 117 through 124 of the header contain an offset to subsystem-specificdata in the MAT-File . All zeros or all spaces in this field indicate that there isno subsystem-specific data stored in the last 4 bytes in the header are divided into two, 16-bit flag fields (int16).FieldValueVersionWhen creating a MAT-File , set this field the two characters,MandI, written to theMAT-file in this order, as a 16-bit value. If, when read fromthe MAT-File as a 16-bit value, the characters appear inreversed order (IMrather thanMI), it indicates that theprogram reading the MAT-File must perform byte-swappingto interpret the data in the MAT-File that create MAT-files always write data in their nativemachine Format .


Related search queries