Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

invalid mxArray returned by mxGetCell...

Status
Not open for further replies.

Markus21783

Electrical
Joined
Mar 28, 2005
Messages
2
Location
ZA
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top