Help to debug mexFunction
이전 댓글 표시
I have a very simple mexFunction but it still causes Matlab to crash. Can someone help to debug where the error is?
#include "geometryMatrix64.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
mxArray *inputLat;
double *arrayLat= NULL;
double *outputGeo= NULL;
int outputRowLen = 0, outputColLen = 0, i = 0, j = 0;
inputLat = prhs[0];
arrayLat = mxGetPr(inputLat);
mexPrintf("Starting...............");
outputRowLen = 3;
outputColLen = 1;
plhs[0] = mxCreateDoubleMatrix(outputRowLen, outputColLen, mxREAL);
outputGeo = mxGetPr(plhs[0]);
for (i=0;i<outputRowLen;i++){
for(j=0; j<outputColLen; j++){
outputGeo[i*outputRowLen+j] = 0;
}
}
mexPrintf("Calculation of geometry matrix done!");
return ;
}
I compiled with the following matlab code:
for i=1:10
i
clear all;
load('parameters.mat')
blaslib = fullfile('C:\Program Files\MATLAB\R2011b\extern\lib\win64\microsoft\libmwblas.lib');
lapacklib = fullfile('C:\Program Files\MATLAB\R2011b\extern\lib\win64\microsoft\libmwlapack.lib');
mex('-largeArrayDims', '-compatibleArrayDims', 'geometryMatrix64.c', 'mathFunction64.c', blaslib, lapacklib)
%[Geoc] = geometryMatrix64(lat, long, incl, peri, seax, GM, r_E, ele_mask, time, theta);
[Geoc] = geometryMatrix64(lat);
end;
On the command window, such message is shown and crashed:
i =
1
Starting...............Calculation of geometry matrix done!
i =
2
Starting...............Calculation of geometry matrix done!
Restarted computer and I got the same result but the iteration went up to i = 3.
I'm sorry for posting so often lately about mex functions. But I'm really stuck and am getting more and more frustrated since a simple mexFunction like this can't even work.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!