1MAT_VARREADNEXT(3) BSD Library Functions Manual MAT_VARREADNEXT(3)
2
4 Mat_VarReadNext — Reads the information and data for the next variable in
5 a MATLAB MAT file.
6
8 #include <matio.h>
9
10 matvar_t *
11 Mat_VarReadNext(mat_t *matfp);
12
14 The Mat_VarReadNext() function reads the information and data for the
15 next variable stored in the open MAT file.
16
18 If there is another variable in the MAT file and is read successfully, a
19 pointer to the MATLAB variable structure is returned. If there are no
20 more variables, or there was an error reading the variable, NULL is
21 returned.
22
24 This example program opens a MAT file named by the first argument to the
25 program, and uses Mat_VarReadNext() to read each variable in the file.
26 For each variable read, the Mat_VarPrint(3) function is used to display
27 the information and data of the variable.
28
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include "matio.h"
32
33 int
34 main(int argc, char **argv)
35 {
36 mat_t *matfp;
37 matvar_t *matvar;
38
39 matfp = Mat_Open(argv[1], MAT_ACC_RDONLY);
40 if ( NULL == matfp ) {
41 fprintf(stderr, "Error opening MAT file %s0, argv[1]);
42 return EXIT_FAILURE;
43 }
44
45 while ( NULL != (matvar = Mat_VarReadNext(matfp)) ) {
46 Mat_VarPrint(matvar, 1);
47 Mat_VarFree(matvar);
48 }
49
50 Mat_Close(matfp);
51 return EXIT_SUCCESS;
52 }
53
55 Mat_VarRead(3), Mat_VarReadNextInfo(3), Mat_VarPrint(3)
56
57BSD September 12, 2019 BSD