필터 지우기
필터 지우기

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

조회 수: 5 (최근 30일)
XAXRXTX
XAXRXTX 2015년 3월 2일
댓글: Guillaume 2015년 3월 2일
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

답변 (1개)

Guillaume
Guillaume 2015년 3월 2일
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
James Tursa
James Tursa 2015년 3월 2일
Yes, you need to write code to copy each field one at a time.
Guillaume
Guillaume 2015년 3월 2일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by