Borrar filtros
Borrar filtros

passing a structure pointer from C mex file to matlab

7 visualizaciones (últimos 30 días)
XAXRXTX
XAXRXTX el 14 de Mzo. de 2017
Editada: XAXRXTX el 15 de Mzo. de 2017
Hi,
I m trying to pass a pointer of a static structure from C mex to matlab, this pointer will be used by another C mex function. any help will be much appreciated thanks in advance

Respuesta aceptada

James Tursa
James Tursa el 14 de Mzo. de 2017
The usual hack is to encapsulate the pointer in a MATLAB uint64 variable. I.e., set the data area of a uint64 mxArray to the value of your pointer and pass that variable around. However, you need to be careful that the pointer is indeed valid to use in that other mex routine or it will cause a MATLAB crash.
  3 comentarios
James Tursa
James Tursa el 15 de Mzo. de 2017
See this link:
https://www.mathworks.com/matlabcentral/answers/75524-returning-and-passing-void-pointers-to-mex-functions?s_tid=answers_rc1-2_p2_MLT
XAXRXTX
XAXRXTX el 15 de Mzo. de 2017
Editada: XAXRXTX el 15 de Mzo. de 2017
to be honest I had a trouble to make it working, but your suggestion in the link about adding an option in the input arguments has fixed the problem, thanks again

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by