Debian Codegraph @

matio-1.5.30/documentation/Mat_VarWriteAppend.3

raw
1 .\" Copyright (c) 2015-2026, The matio contributors
2 .\" Copyright (c) 2012-2014, Christopher C. Hulbert
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\"
8 .\" 1. Redistributions of source code must retain the above copyright notice, this
9 .\" list of conditions and the following disclaimer.
10 .\"
11 .\" 2. Redistributions in binary form must reproduce the above copyright notice,
12 .\" this list of conditions and the following disclaimer in the documentation
13 .\" and/or other materials provided with the distribution.
14 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 .\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 .\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 .\"
26 .Dd September 12, 2019
27 .Dt MAT_VARWRITEAPPEND 3
28 .Os
29 .Sh NAME
30 .Nm Mat_VarWriteAppend
31 .Nd Writes/appends a MATLAB variable to an HDF5 format MATLAB MAT file.
32 .Sh SYNOPSIS
33 .Fd #include <matio.h>
34 .Ft int
35 .Fo Mat_VarWriteAppend
36 .Fa "mat_t *matfp"
37 .Fa "matvar_t *matvar"
38 .Fa "enum matio_compression compress"
39 .Fa "int dim"
40 .Fc
41 .Sh DESCRIPTION
42 The
43 .Fn Mat_VarWriteAppend
44 function writes (and optionally appends) the MATLAB variable
45 .Fa matvar
46 to the MAT file
47 .Fa matfp
48 which must be opened for writing.
49 If the MATLAB variable already exists in the MAT file, the new data is appended
50 to this variable along the (index 1 based) dimension
51 .Fa d .
52 The
53 .Fa compress
54 option allows the variable to be written using zlib compression if available.
55 If compression is not available, the variable is written uncompressed.
56 .Sh RETURN VALUES
57 The function returns 0 if the variable was successfully written/appended to the
58 MAT file.
59 Otherwise, an error value is returned.
60 .Sh EXAMPLES
61 This example program creates a MAT file named by the first argument to the
62 program, and writes the variable named
63 .Em m_pi
64 to the file in order to build a 2x1 array.
65 .Bd -literal
66 #include <math.h>
67 #include "matio.h"
68
69 int
70 main(int argc, char **argv)
71 {
72 mat_t *matfp;
73 matvar_t *matvar;
74 size_t dims[2] = {1, 1};
75 double m_pi = M_PI;
76
77 matfp = Mat_CreateVer(argv[1], NULL, MAT_FT_MAT73);
78 if ( NULL == matfp ) {
79 fprintf(stderr, "Error creating MAT file %s\n", argv[1]);
80 return EXIT_FAILURE;
81 }
82
83 matvar = Mat_VarCreate("m_pi", MAT_C_DOUBLE, MAT_T_DOUBLE,
84 2, dims, &m_pi, 0);
85 if ( NULL != matvar ) {
86 int dim = 1;
87 Mat_VarWriteAppend(matfp, matvar, MAT_COMPRESSION_ZLIB, dim);
88 Mat_VarWriteAppend(matfp, matvar, MAT_COMPRESSION_ZLIB, dim);
89 Mat_VarFree(matvar);
90 }
91
92 Mat_Close(matfp);
93 return EXIT_SUCCESS;
94 }
95
96 .Ed
97 .Sh SEE ALSO
98 .Xr Mat_CreateVer 3 ,
99 .Xr Mat_Open 3 ,
100 .Xr Mat_VarRead 3 ,
101 .Xr Mat_VarWrite 3