User`s manual

Examples of MAT-Files
6-17
* matClose
* matGetDir
* matGetNextArray
* matGetNextArrayHeader
* matOpen
*
* Copyright (c) 1984-1998 The MathWorks, Inc.
*/
#include <stdio.h>
#include <stdlib.h>
#include "string.h"
#include "mat.h"
int diagnose(const char *file) {
MATFile *pmat;
char **dir;
int ndir;
int i;
mxArray *pa;
printf("Reading file %s...\n\n", file);
/* Open file to get directory. */
pmat = matOpen(file, "r");
if (pmat == NULL) {
printf("Error opening file %s\n", file);
return(1);
}
/* Get directory of MAT-file. */
dir = matGetDir(pmat, &ndir);
if (dir == NULL) {
printf("Error reading directory of file %s\n", file);
return(1);
} else {
printf("Directory of %s:\n", file);
for (i=0; i < ndir; i++)
printf("%s\n",dir[i]);
}