MATLAB C API to Read MAT-File Data

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

When you program your entire application in MATLAB or when you share data with other MATLAB users, use these MATLAB procedures.

There are situations, however, when you must write a custom program to interact with data. For example:

  • Your data has a custom format.

  • You create applications for users who do not run MATLAB, and you want to provide them with MATLAB data.

  • You want to read data from an external application, but you do not have access to the source code.

C MAT-File API

matOpenOpen MAT-file
matCloseClose MAT-file
MATFileType for MAT-file
matGetVariableArray from MAT-file
matGetVariableInfoArray header information only
matGetNextVariableNext array in MAT-file
matGetNextVariableInfoArray header information only
matPutVariableArray to MAT-file
matPutVariableAsGlobalArray to MAT-file as originating from global workspace
matDeleteVariableDelete array from MAT-file
matGetDirList of variables in MAT-file
matGetFpFile pointer to MAT-file
mxIsFromGlobalWSDetermine whether mxArray was copied from MATLAB global workspace
matGetErrnoError codes for MAT-file API

Topics

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.

Custom Applications to Access MAT-Files

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

Share MAT-File Applications

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

Related Information