MATLAB Application Program Interface Reference | Help Desk |
matPutArrayAsGlobal
Put mxArrays into MAT-files
#include "mat.h" int matPutArrayAsGlobal(MATFile *mfp, const mxArray *mp);
mfp
Pointer to MAT-file information.
mp
This routine allows you to put an mxArray into a MAT-file. matPutArrayAsGlobal
is similar to matPutArray
, except the array is loaded by MATLAB into the global workspace and a reference to it is set in the local workspace. If you write to a MATLAB 4 format file, matPutArrayAsGlobal
will not load it as global, and will act the same as matPutArray
.
matPutArrayAsGlobal
writes mxArray mp
to the MAT-file mfp
. If the mxArray does not exist in the MAT-file, it is appended to the end. If an mxArray with the same name already exists in the file, the existing mxArray is replaced with the new mxArray by rewriting the file. The size of the new mxArray can be different than the existing mxArray.
matPutArrayAsGlobal
returns 0 if successful and nonzero if an error occurs. Use feof
and ferror
from the Standard C Library with matGetFp
to determine status.
See matdemo.c
in the eng_mat
subdirectory of the examples
directory for a sample program that illustrates how to use the MATLAB MAT-file routines in a C program.