-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathMat_VarWrite.3
More file actions
75 lines (70 loc) · 1.81 KB
/
Mat_VarWrite.3
File metadata and controls
75 lines (70 loc) · 1.81 KB
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
.\" Copyright (c) 2015-2026, The matio contributors
.\" Copyright (c) 2012-2014, Christopher C. Hulbert
.\" All rights reserved.
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.Dd September 12, 2019
.Dt MAT_VARWRITE 3
.Os
.Sh NAME
.Nm Mat_VarWrite
.Nd Writes a MATLAB variable to a MATLAB MAT file.
.Sh SYNOPSIS
.Fd #include <matio.h>
.Ft int
.Fo Mat_VarWrite
.Fa "mat_t *matfp"
.Fa "matvar_t *matvar"
.Fa "enum matio_compression compress"
.Fc
.Sh DESCRIPTION
The
.Fn Mat_VarWrite
function writes the MATLAB variable
.Fa matvar
to the MAT file
.Fa matfp
which must be opened for writing. If the MAT file is a version 5 or HDF5 MAT
file, 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 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.
.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_DEFAULT);
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 ) {
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB);
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_VarWriteAppend 3