Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Passing different data type between various mex functions from within matlab

1 visualizzazione (ultimi 30 giorni)
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 Commento
James Tursa
James Tursa il 3 Giu 2016
Are the mex functions written by you? I.e., do you have the source code for them and can modify them?

Risposte (0)

Questa domanda è chiusa.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by