Help to debug mexFunction
Show older comments
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.
1 Comment
Jane Jean
on 28 Mar 2012
Accepted Answer
More Answers (0)
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!