1MAT_VARWRITEAPPEND(3)    BSD Library Functions Manual    MAT_VARWRITEAPPEND(3)
2

NAME

4     Mat_VarWriteAppend — Writes/appends a MATLAB variable to an HDF5 format
5     MATLAB MAT file.
6

SYNOPSIS

8     #include <matio.h>
9
10     int
11     Mat_VarWriteAppend(mat_t *matfp, matvar_t *matvar,
12         enum matio_compression compress, int dim);
13

DESCRIPTION

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

RETURN VALUES

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

EXAMPLES

28     This example program creates a MAT file named by the first argument to
29     the program, and writes the variable named m_pi to the file in order to
30     build a 2x1 array.
31
32     #include <math.h>
33     #include "matio.h"
34
35     int
36     main(int argc, char **argv)
37     {
38         mat_t    *matfp;
39         matvar_t *matvar;
40         size_t    dims[2] = {1, 1};
41         double    m_pi = M_PI;
42
43         matfp = Mat_CreateVer(argv[1], NULL, MAT_FT_MAT73);
44         if ( NULL == matfp ) {
45             fprintf(stderr, "Error creating MAT file %s0, argv[1]);
46             return EXIT_FAILURE;
47         }
48
49         matvar = Mat_VarCreate("m_pi", MAT_C_DOUBLE, MAT_T_DOUBLE,
50                                2, dims, &m_pi, 0);
51         if ( NULL != matvar ) {
52             int dim = 1;
53             Mat_VarWriteAppend(matfp, matvar, MAT_COMPRESSION_ZLIB, dim);
54             Mat_VarWriteAppend(matfp, matvar, MAT_COMPRESSION_ZLIB, dim);
55             Mat_VarFree(matvar);
56         }
57
58         Mat_Close(matfp);
59         return EXIT_SUCCESS;
60     }
61
62

SEE ALSO

64     Mat_CreateVer(3), Mat_Open(3), Mat_VarRead(3), Mat_VarWrite(3)
65
66BSD                           September 12, 2019                           BSD
Impressum