In a Mex file, a for loop goes beyond the relational expression?
Show older comments
I keep getting a crash in a mex file. I have no clue why there is a problem other than using mwSize instead of something else.
here is code cut down to only the problem
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
mwSize t, T;
T = mxGetN(prhs[0]);
for( t = T - 2; t >= 0; t--){
mexPrintf("Smooth %d\n",t);
mexEvalString("drawnow;");
}/*end of t=T-2:0;*/
return;
}
this gets compiled with the -largeArrayDims flag.
then in matlab:
a= zeros(50,200); and run the above on a
I expect the printed t to go from 198 to 0 and then stop. Instead, it runs into negative numbers and doesn't stop unless killed.
Anyone know why?
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!