Changeset 12037
- Timestamp:
- 04/17/12 19:04:15 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/matlab/io/WriteMatlabData.cpp
r12022 r12037 33 33 #endif 34 34 35 /*Now transpose the matrix : */35 /*Now transpose the matrix and allocate with Matlab's memory manager: */ 36 36 tmatrix_ptr=(double*)mxMalloc(rows*cols*sizeof(double)); 37 37 for(i=0;i<cols;i++){ … … 63 63 mxArray* dataref=NULL; 64 64 double* vector_ptr=NULL; 65 double* vector_ptr2=NULL; 65 66 int rows; 66 67 … … 74 75 #endif 75 76 76 /*now create the matlab vector: */ 77 /*now create the matlab vector with Matlab's memory manager */ 78 vector_ptr2=(double*)mxMalloc(rows*sizeof(double)); 79 for(int i=0;i<rows;i++) vector_ptr2[i]=vector_ptr[i]; 80 77 81 dataref = mxCreateDoubleMatrix(0,0,mxREAL); 78 82 mxSetM(dataref,rows); 79 83 mxSetN(dataref,1); 80 mxSetPr(dataref,vector_ptr );84 mxSetPr(dataref,vector_ptr2); 81 85 } 82 86 else{ 83 87 dataref = mxCreateDoubleMatrix(0,0,mxREAL); 84 88 } 89 90 /*Clean-up and return*/ 91 xfree((void**)&vector_ptr); 85 92 *pdataref=dataref; 86 87 93 } 88 94 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.