User`s manual

Examples of MAT-Files
6-11
Examples of MAT-Files
This section includes C and Fortran examples of writing, reading, and
diagnosing MAT-files. The examples cover the following topics:
“Creating a MAT-File in C”
“Reading a MAT-File in C”
“Creating a MAT-File in Fortran”
“Reading a MAT-File in Fortran”
Creating a MAT-File in C
This sample program illustrates how to use the library routines to create a
MAT-file that can be loaded into MATLAB. The program also demonstrates
how to check the return values of MAT-function calls for read or write failures.
/*
* MAT-file creation program
*
* See the MATLAB API Guide for compiling information.
*
* Calling syntax:
*
* matcreat
*
* Create a MAT-file which can be loaded into MATLAB.
*
* This program demonstrates the use of the following functions:
*
* matClose
* matGetArray
* matOpen
* matPutArray
* matPutArrayAsGlobal
*
* Copyright 1984-2000 The MathWorks, Inc.
*/
/* $Revision: 1.10 $ */
#include <stdio.h>
#include <string.h> /* For strcmp() */