This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Applications to Read MAT-File Data

Read and write MATLAB® data from C/C++ and Fortran programs

C and Fortran MAT-File Library Functions

matOpen (C and Fortran)Open MAT-file
matClose (C and Fortran)Close MAT-file
MATFile (C and Fortran)Type for MAT-file
matGetVariable (C and Fortran)Array from MAT-file
matGetVariableInfo (C and Fortran)Array header information only
matGetNextVariable (C and Fortran)Next array in MAT-file
matGetNextVariableInfo (C and Fortran)Array header information only
matPutVariable (C and Fortran)Array to MAT-file
matPutVariableAsGlobal (C and Fortran)Array to MAT-file as originating from global workspace
matDeleteVariable (C and Fortran)Delete array from MAT-file
matGetDir (C and Fortran)List of variables in MAT-file
matGetFp (C)File pointer to MAT-file
mxIsFromGlobalWS (C and Fortran)Determine whether array was copied from MATLAB global workspace

Examples and How To

Table of MAT-File Source Code Files

The matlabroot/extern/examples/eng_mat folder contains C/C++ and Fortran source code for examples demonstrating how to use the MAT-file routines.

Create MAT-File in C or C++

The matcreat.c example illustrates how to use the library routines to create a MAT-file that you can load into the MATLAB workspace.

Read MAT-File in C/C++

The matdgns.c example illustrates how to use the library routines to read and diagnose a MAT-file.

Create MAT-File in Fortran

The matdemo1.F example creates the MAT-file, matdemo.mat.

Read MAT-File in Fortran

The matdemo2.F example illustrates how to use the library routines to read the MAT-file created by matdemo1.F and describe its contents.

Work with mxArrays

The MAT-File Interface Library lets you access MATLAB arrays (type mxArray) in a MAT-file.

Copy External Data into MAT-File Format with Standalone Programs

This topic shows how to create a standalone program, matimport, to copy data from an external source into a MAT-file.


Custom Applications to Access MAT-Files

Methods of importing and exporting MATLAB data, and MAT-file routines that enable you to do this

What You Need to Build Custom Applications

To create a custom application, you need the tools and knowledge to modify and build source code.

MAT-File Library and Include Files

MATLAB provides include and library files to write programs to read and write MAT-files.

Build on Mac and Linux Operating Systems

At run time, you must tell the Mac and Linux® operating system where the API shared libraries reside by setting an environment variable.

Build on Windows Operating Systems

To compile and link MAT-file programs, use the mex script with the -client engine option.

Share MAT-File Applications

MATLAB requires shared library files for building any MAT-file application.

Was this topic helpful?