Write C Programs to Read MAT-File Data
mxArray
When you program your entire application in MATLAB or when you share data with other MATLAB users, use these MATLAB procedures.
To bring data into a MATLAB application, use Supported File Formats for Import and Export.
To save data to a MAT-file, use Save and Load Workspace Variables.
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
matOpen | Open MAT-file |
matClose | Close MAT-file |
MATFile | Type for MAT-file |
matGetVariable | Array from MAT-file |
matGetVariableInfo | Array header information only |
matGetNextVariable | Next array in MAT-file |
matGetNextVariableInfo | Array header information only |
matPutVariable | Array to MAT-file |
matPutVariableAsGlobal | Array to MAT-file as originating from global workspace |
matDeleteVariable | Delete array from MAT-file |
matGetDir | List of variables in MAT-file |
matGetFp | File pointer to MAT-file |
mxIsFromGlobalWS | Determine whether mxArray was copied from MATLAB global workspace |
matGetErrno | Error 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. - Create Custom Programs to Read MAT-Files
Methods for importing and exporting MATLAB data with MAT-file functions using
mxArray
. - Share MAT-File Applications
MATLAB requires shared library files for building a MAT-file application.