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

 채택된 답변

James Tursa
James Tursa 2017년 3월 14일

0 개 추천

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

thanks for the reply James, do you have some example about pointer encapsulation in MATLAB ?
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 2017년 3월 15일
편집: XAXRXTX 2017년 3월 15일
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

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

질문:

2017년 3월 14일

편집:

2017년 3월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by