Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

Passing different data type between various mex functions from within matlab

1 view (last 30 days)
Suppose I want to pass a pointer to different data type to pass between various functions in Matlab, can I do it?
For e.g: Suppose the library in C I use two structure pointers "ghkModel* m" and "ghkData* d". These are library specific data types. These are two large structures that contains various fields. I need to preserve the content of ghkData *d since it is used later by varous functions.
Is there a way to do this:
For example, this is what I want to do:
myMatlabFunction()
[m, d] = C_mex_funtion_1(); % m and d contains the structure ghkModel and ghkData
[p, q] = C_mex_function_2(m,d);
rslt = C_mex_function_3(p,q, m,d);
end
Basically question is how to pass in data that is not of type mxArray to other mex functions within matlab code?
And how to allocate memory to it? I mean in the mex entry point.
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
ghkModel* m = mxGetPr(prhs[0]);
ghkData* d = mxGetPr(prhs[1]);
callSomeFunction(m,d);
}
Any helpful suggestion is appreciated.
  1 Comment
James Tursa
James Tursa on 3 Jun 2016
Are the mex functions written by you? I.e., do you have the source code for them and can modify them?

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!