home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / SRC.DI$ / MATTEST1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-26  |  594 b   |  31 lines

  1. /*
  2.  *    MATTEST1
  3.  *
  4.  *    Simple program that illustrates how to call the MAT-file Library
  5.  *    from a C program.  
  6.  *
  7.  *    The example writes a simple 3-by-2 real matrix into a MAT-file.
  8.  *    The matrix is named, "A", and the MAT-file is named, "foo.mat".
  9.  *    
  10.  */
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include "mat.h"
  14.  
  15. static double Areal[6] = { 1, 2, 3, 4, 5, 6 };
  16.  
  17. main()
  18. {
  19.     MATFile *fp;
  20.     Matrix *a;
  21.  
  22.     fp = matOpen("foo.mat", "w");
  23.     a = mxCreateFull(3, 2, REAL);
  24.     memcpy(mxGetPr(a), Areal, 6*sizeof(double));
  25.     mxSetName(a, "A");
  26.     matPutMatrix(fp, a);
  27.     matClose(fp);
  28.     mxFreeMatrix(a);
  29.     exit(0);
  30. }
  31.