Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Passing different data type between various mex functions from within matlab

1 Ansicht (letzte 30 Tage)
Michael Mathew
Michael Mathew am 3 Jun. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentar
James Tursa
James Tursa am 3 Jun. 2016
Are the mex functions written by you? I.e., do you have the source code for them and can modify them?

Antworten (0)

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by