MEX: pointers to a matlab structure

2 次查看(过去 30 天)
Petr
Petr 2013-8-28
Hello,
I have the following problem. There is a Matlab structure as follows:
d(1).x=uint32([1 4 6 7 ]);
d(1).y=single([3.3 2.5 3.5 4.4]);
d(2).x=uint32([6 1 7 ]);
d(2).y=single([2.5 3.8 4.4]);
....
d(n).x=uint32(...
d(n).y=single(...
The structure "d" is huge (40GB). I need to do some fast calculation with it. How can I get pointers e.g. d(2).x(3) and d(2).y(3) in MEX?
PETR

回答(1 个)

Kaustubha Govind
Kaustubha Govind 2013-8-28
You need to use mxGetField to access structure fields and mxGetData to access data in a numeric array. If you'd like to see an example, I'd recommend $matlab/extern/examples/refbook/phonebook.c (where $matlab is the location of your MATLAB installation). There are other examples for the MEX API in the same directory.

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler SDK 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by