User`s manual

6 Importing and Exporting Data
6-14
if (status != 0) {
printf("%s : Error using matPutArray on line %d\n",
__FILE__, __LINE__);
return(EXIT_FAILURE);
}
/* clean up */
mxDestroyArray(pa1);
mxDestroyArray(pa2);
mxDestroyArray(pa3);
if (matClose(pmat) != 0) {
printf("Error closing file %s\n",file);
return(EXIT_FAILURE);
}
/*
* Reopen file and verify its contents with matGetArray
*/
pmat = matOpen(file, "r");
if (pmat == NULL) {
printf("Error reopening file %s\n", file);
return(EXIT_FAILURE);
}
/*
* Read in each array we just wrote
*/
pa1 = matGetArray(pmat, "LocalDouble");
if (pa1 == NULL) {
printf("Error reading existing matrix LocalDouble\n");
return(EXIT_FAILURE);
}
if (mxGetNumberOfDimensions(pa1) != 2) {
printf("Error saving matrix: result does not have two
dimensions\n");
return(EXIT_FAILURE);
}