×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

invalid mxArray returned by mxGetCell...

invalid mxArray returned by mxGetCell...

invalid mxArray returned by mxGetCell...

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources