23 pGMatlabDataFileConfig->
FileName[0] =
'\0';
25 sprintf(pGMatlabDataFileConfig->
FileName,
"%s",dirname);
26 strcat(pGMatlabDataFileConfig->
FileName,filename);
29 pGMatlabDataFileConfig->
fp = fopen(pGMatlabDataFileConfig->
FileName,
"w");
30 if(pGMatlabDataFileConfig->
fp==NULL){
31 printf(
"\n pGMatlabDataFileConfig->fp==NULL: %s",pGMatlabDataFileConfig->
FileName);
34 rewind(pGMatlabDataFileConfig->
fp);
42 pGMatlabDataFileConfig->
FileName[0] =
'\0';
44 sprintf(pGMatlabDataFileConfig->
FileName,
"%s",dirname);
45 strcat(pGMatlabDataFileConfig->
FileName,filename);
48 pGMatlabDataFileConfig->
fp = fopen(pGMatlabDataFileConfig->
FileName,
"r");
49 if(pGMatlabDataFileConfig->
fp==NULL){
52 rewind(pGMatlabDataFileConfig->
fp);
60 fclose(pGMatlabDataFileConfig->
fp);
68 DataHead.
type = (long)(0);
69 DataHead.
mrows = (long)(nlin);
70 DataHead.
ncols = (long)(1);
71 DataHead.
imagf = (long)(0);
72 DataHead.
namlen = (long)(strlen(varname)+1);
78 if(! fwrite(varname,
sizeof(
char), (strlen(varname)+1), pGMatlabDataFileConfig->
fp)){
82 if(! fwrite(v,
sizeof(
double), nlin, pGMatlabDataFileConfig->
fp)){
98 DataHead.
type = (long)(0);
99 DataHead.
mrows = (long)(nlin);
100 DataHead.
ncols = (long)(ncol);
101 DataHead.
imagf = (long)(0);
102 DataHead.
namlen = (long)(strlen(varname)+1);
104 if(! fwrite(&DataHead,
sizeof(
MATLAB_DATAHEAD), 1, pGMatlabDataFileConfig->
fp) ){
108 if(! fwrite(varname,
sizeof(
char), (strlen(varname)+1), pGMatlabDataFileConfig->
fp)){
112 vcol = (
double*)malloc(nlin*
sizeof(
double));
114 for(nc=0;nc<ncol;++nc){
115 for(nl=0;nl<nlin;++nl){
116 vcol[nl] = m[nl][nc];
118 if(! fwrite(vcol,
sizeof(
double), nlin, pGMatlabDataFileConfig->
fp)){
int gMATLABDataFile_SaveVector(PGMATLABDATAFILECONFIG pGMatlabDataFileConfig, const char *varname, double *v, long nlin)
void gMATLABDataFile_Close(PGMATLABDATAFILECONFIG pGMatlabDataFileConfig)
int gMATLABDataFile_OpenWrite(PGMATLABDATAFILECONFIG pGMatlabDataFileConfig, char *filename, char *dirname)
int gMATLABDataFile_SaveMatrix(PGMATLABDATAFILECONFIG pGMatlabDataFileConfig, const char *varname, double **m, long nlin, long ncol)
int gMATLABDataFile_OpenRead(PGMATLABDATAFILECONFIG pGMatlabDataFileConfig, char *filename, char *dirname)
struct MATLAB_DATAHEAD * PMATLAB_DATAHEAD