#include <stdio.h>

main(argc,argv)
int argc;
char *argv[];
{


        FILE *fp;
 	char name[20];
 	int type, mrows, ncols, imagf;
 	double *xr, *xi;
        fprintf(stderr,"welcome to %s\n", argv[0]);

        if (argc==1) {                                         /*help */
            fprintf(stderr,"use: %s deleteme.mat\n", argv[0]);
            exit(-1);
        }

 	fp = fopen(argv[1],"rb");
        if (fp==NULL)  {perror(argv[0]);  exit(-1);}
        loadmat(fp, &type, name, &mrows, &ncols, &imagf, &xr, &xi);
        fclose(fp);
 	free(xr);
 	if (imagf) free(xi);

        fprintf(stdout,"HEADER INFO:\n");
        fprintf(stdout,"decimal digits for type (Machine, Orientation, Precis, asc. Text)= %d\n",type);
        fprintf(stdout,"mrows               = %d\n",mrows);
        fprintf(stdout,"ncols               = %d\n",ncols);
        fprintf(stdout,"imagf (0 for real)  = %d\n",imagf);
        fprintf(stdout,"name  (NUL at end)  = %s\n",name);

        fprintf(stdout,"first datum = %f (valid only for double .mat files)\n", xr[0]);

}

