manpagez: man pages & more
man Mat_VarWriteAppend(3)
Home | html | info | man

Mat_VarWriteAppend(3)    BSD Library Functions Manual    Mat_VarWriteAppend(3)


NAME

     Mat_VarWriteAppend -- Writes/appends a MATLAB variable to an HDF5 format
     MATLAB MAT file.


SYNOPSIS

     #include <matio.h>

     int
     Mat_VarWriteAppend(mat_t *matfp, matvar_t *matvar,
         enum matio_compression compress, int dim);


DESCRIPTION

     The Mat_VarWriteAppend() function writes (and optionally appends) the
     MATLAB variable matvar to the MAT file matfp which must be opened for
     writing.  If the MATLAB variable already exists in the MAT file, the new
     data is appended to this variable along the (index 1 based) dimension d.
     The compress option allows the variable to be written using zlib compres-
     sion if available.  If compression is not available, the variable is
     written uncompressed.


RETURN VALUES

     The function returns 0 if the variable was successfully written/appended
     to the MAT file.  Otherwise, an error value is returned.


EXAMPLES

     This example program creates a MAT file named by the first argument to
     the program, and writes the variable named m_pi to the file in order to
     build a 2x1 array.

     #include <math.h>
     #include "matio.h"

     int
     main(int argc,char **argv)
     {
         mat_t    *matfp;
         matvar_t *matvar;
         size_t    dims[2] = {1,1};
         double    m_pi = M_PI;

         matfp = Mat_CreateVer(argv[1],NULL,MAT_FT_MAT73);
         if ( NULL == matfp ) {
             fprintf(stderr,"Error creating MAT file %s0,argv[1]);
             return EXIT_FAILURE;
         }

         matvar = Mat_VarCreate("m_pi",MAT_C_DOUBLE,MAT_T_DOUBLE,2,dims,&m_pi,0);
         if ( NULL != matvar ) {
             int dim = 1;
             Mat_VarWriteAppend(matfp,matvar,MAT_COMPRESSION_ZLIB,dim);
             Mat_VarWriteAppend(matfp,matvar,MAT_COMPRESSION_ZLIB,dim);
             Mat_VarFree(matvar);
         }

         Mat_Close(matfp);
         return EXIT_SUCCESS;
     }



SEE ALSO

     Mat_CreateVer(3), Mat_Open(3), Mat_VarRead(3), Mat_VarWrite(3)

BSD                            October 19, 2017                            BSD

matio 1.5.11 - Generated Thu Oct 26 07:34:44 CDT 2017
© manpagez.com 2000-2025
Individual documents may contain additional copyright information.