Borrar filtros
Borrar filtros

return the pointer or the structure of C structure in C mex file

4 visualizaciones (últimos 30 días)
XAXRXTX
XAXRXTX el 2 de Mzo. de 2015
Comentada: Guillaume el 2 de Mzo. de 2015
Hi
I have a C function inside a mex file that return a large structure ( 110 fields ), and I want to return this structure to matlab , so , my question is how to copy or to return the pointer of the C structure to Matlab ?
thanks in advance

Respuestas (1)

Guillaume
Guillaume el 2 de Mzo. de 2015
You can't, matlab does not understand C structures. You'll have to convert your structure to a matlab structure (which is a very different beast). See mxcreatestructarray and mxsetfield to create matlab structs.
  3 comentarios
James Tursa
James Tursa el 2 de Mzo. de 2015
Yes, you need to write code to copy each field one at a time.
Guillaume
Guillaume el 2 de Mzo. de 2015
Unless all the fields are the same type, I don't see any other way but to copy each field one by one I'm afraid.

Iniciar sesión para comentar.

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