User`s manual

6 Importing and Exporting Data
6-6
Both types of files can be transported directly between machines: M-files
because they are platform independent and MAT-files because they contain a
machine signature in the file header. MATLAB checks the signature when it
loads a file and, if a signature indicates that a file is foreign, performs the
necessary conversion.
Using MATLAB across several different machine architectures requires a
facility for exchanging both binary and ASCII data between the various
machines. Examples of this type of facility include FTP, NFS, Kermit, and
other communication programs. When using these programs, be careful to
transmit binary MAT-files in binary file mode and ASCII M-files in ASCII file
mode. Failure to set these modes correctly corrupts the data.
Reading and Writing MAT-Files
The save command in MATLAB saves the MATLAB arrays currently in
memory to a binary disk file called a MAT-file. The term MAT-file is used
because these files have the extension
.mat. The load command performs the
reverse operation. It reads the MATLAB arrays from a MAT-file on disk back
into MATLAB’s workspace.
A MAT-file may contain one or more of any of the data types supported in
MATLAB 5 or later, including strings, matrices, multidimensional arrays,
structures, and cell arrays. MATLAB writes the data sequentially onto disk as
a continuous byte stream.
MAT-File Interface Library
The MAT-file interface library contains a set of routines for reading and
writing MAT-files. You can call these routines from within your own C and
Fortran programs. We recommend that you use these routines, rather than
attempt to write your own code, to perform these operations. By using the
routines in this library, you will be insulated from future changes to the
MAT-file structure.