Markus21783
Electrical
- Mar 28, 2005
- 2
Hello all mexperts!
My problem is: when I use the following code, it will crash if I say
>>a = cell(2,2); >>myfun(a)
where myfun(a) is the function:
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray
*prhs[])
{
int index;
mxArray *cell_element_ptr = 0;
double *out;
int dims[2] = {1,1};
index = mxCalcSingleSubscript(prhs[0], 2, dims);
cell_element_ptr = mxGetCell(prhs[0], index);
printf("ptr: %i ", (int) cell_element_ptr);
out = (double *) mxGetPr(cell_element_ptr);
}
The value for cell_element_ptr is 0, and I guess this is because that
cell entry is empty. But if I fill that entry with >>a{2,2} =
1; then >>a{2,2} = []; the function displays a different value
for cell_element_ptr. What is going on? Is there some function I
can call to see if the mxGetCell has returned a nonempty matrix?
thanks,
Markus
My problem is: when I use the following code, it will crash if I say
>>a = cell(2,2); >>myfun(a)
where myfun(a) is the function:
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray
*prhs[])
{
int index;
mxArray *cell_element_ptr = 0;
double *out;
int dims[2] = {1,1};
index = mxCalcSingleSubscript(prhs[0], 2, dims);
cell_element_ptr = mxGetCell(prhs[0], index);
printf("ptr: %i ", (int) cell_element_ptr);
out = (double *) mxGetPr(cell_element_ptr);
}
The value for cell_element_ptr is 0, and I guess this is because that
cell entry is empty. But if I fill that entry with >>a{2,2} =
1; then >>a{2,2} = []; the function displays a different value
for cell_element_ptr. What is going on? Is there some function I
can call to see if the mxGetCell has returned a nonempty matrix?
thanks,
Markus