Passing containers.Map to MEX file

1 view (last 30 days)
How do you pass a containers.Map object to a MEX file? How do you access the data from inside the MEX file?

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 13 May 2011
Hi,
passing the variable is easy: just use it ;-). O.K., serious now. Passing is not the problem but doing anything meaningful will be. You will be able to call methods using mexCallMATLAB, e.g.,
/* cmap.c */
void mexFunction(int nlhs, mxArray* plhs[],
int nrhs, const mxArray* prhs[]) {
mexCallMATLAB(1, plhs, 2, prhs, "isKey");
}
and in MATLAB:
x = containers.Map('foo', 42);
v = cmap(x, 'foo');
Otherwise: pass x.keys and x.values to mex function and work with the two cell arrays ...
Titus
  1 Comment
Alex
Alex on 13 May 2011
Hey thank you so much for the quick response!

Sign in to comment.

More Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!