| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
#include "mat.h" MATFile *matOpen(const char *filename, const char *mode);
mwPointer matOpen(filename, mode) character*(*) filename, mode
Name of file to open
File opening mode. Valid values for mode are listed in the following table.
Opens file for reading only; determines the current version of the MAT-file by inspecting the files and preserves the current version. | |
Opens file for update, both reading and writing, but does not create the file if the file does not exist (equivalent to the r+ mode of fopen); determines the current version of the MAT-file by inspecting the files and preserves the current version. | |
Opens file for writing only; deletes previous contents, if any. | |
Creates a Level 4 MAT-file, compatible with MATLAB Versions 4 software and earlier. | |
Opens file for writing character data using the default character set for your system. The resulting MAT-file can be read with MATLAB Version 6 or 6.5 software. If you do not use the wL mode switch, MATLAB writes character data to the MAT-file using Unicode® character encoding by default. | |
Opens file for writing compressed data. | |
w7.3 | Creates a MAT-file in an HDF5-based format that can store objects occupy more than 2 GB. |
File handle, or NULL in C (0 in Fortran) if the open fails.
This routine opens a MAT-file for reading and writing.
See Writing Character Data in the External Interfaces documentation for more information on how MATLAB uses character encodings.
See matcreat.c and matdgns.c in the matlabroot/extern/examples/eng_mat folder for sample programs that illustrate how to use the MAT-file routines in a C program.
See matdemo1.F and matdemo2.F in the matlabroot/extern/examples/eng_mat folder for sample programs that illustrate how to use the MAT-file routines in a Fortran program.
![]() | matGetVariableInfo (C and Fortran) | matPutVariable (C and Fortran) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |