I've been at this for a couple days now, have tried every variation I can think of, and looked at countless examples. I just can't get it working.
I'm trying to make a mexFunction to call from matlab. This mexFunction calls into another C function I have, lets call it retrieveValues, and returns an array and the length of that array. I need to return both of those back to the matlab function, which as I understand it, means I need to put them in the plhs
array.
I call my mexFunction from matlab like this:
[foofooArray, foofooCount] = getFoo();
Which to my understanding, means that nlhs = 2
, plhs
is an array of length 2, nrhs = 0
, and prhs
just a pointer.
Here's my code for the mexFunction:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray* prhs[])
{
foo* fooArray
int fooCount
plhs = mxCreateNumericMatrix(1, 2, mxUINT64_CLASS, mxREAL);
//feels like I shouldn't need this
retrieveValues(&fooArray, &fooCount);
plhs[0] = fooArray;
plhs[1] = fooCount;
}
Running the matlab program gets me One or more output arguments not assigned during call
I've tested and confirmed that the values are being returned from retrieveValues
correctly.