diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 2340c78bf1..9fd67a6dbb 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -88,16 +88,19 @@ int write_file_matlab(const char *fname, void *data, int length, int dec, - char format) + unsigned int format) { FILE *fp=NULL; int i; + AssertFatal((format&~MATLAB_RAW) <16,""); + if (data == NULL) return -1; //printf("Writing %d elements of type %d to %s\n",length,format,fname); + if (format == 10 || format ==11 || format == 12 || format == 13 || format == 14) { fp = fopen(fname,"a+"); } else if (format != 10 && format !=11 && format != 12 && format != 13 && format != 14) { @@ -109,6 +112,32 @@ int write_file_matlab(const char *fname, return(-1); } + if ( (format&MATLAB_RAW) == MATLAB_RAW ) { + int sz[16]={sizeof(short), 2*sizeof(short), + sizeof(int), 2*sizeof(int), + sizeof(char), 2*sizeof(char), + sizeof(long long), + sizeof(double), 2*sizeof(double), + sizeof(unsigned char), + sizeof(short), + sizeof(short), + sizeof(short), + sizeof(short), + sizeof(short), + sizeof(short) + }; + int eltSz= sz[format&~MATLAB_RAW]; + if (dec==1) + fwrite(data, eltSz, length, fp); + else + for (i=0; i