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