.\" 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 .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 #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