Hi,
I have written some code in Matlab and would like to convert it to mex (C++) for now and later to C++ completely. In matlab, my function receives an array of structures as input. What is the best way for me to transfer this data from matlab to mex and then later on to C++.
The data being received as input has the following size and formatting: size(inputStruct) = 1 x 100; each structure has the following fields : size(inputStruct(1,1).a) = 10 x 10; size(inputStruct(1,1).m) = 8 x 30; size(inputStruct(1,1).b) = 1 x 8; size(inputStruct(1,1).c) = 1 x 10 (cells); where each cell contains a 30 x 30 matrix.

 채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 7월 25일

0 개 추천

You can pass the structure on to your MEX-file as is, but the real question is how would you access the fields of the structure array (which is available as an mxArray). Once you can access the field names and values, you could potentially convert it to a C structure array. There are a few examples referred to at the bottom of this documentation page that you can follow to understand how to access mxArray structures. You might find the explore.c example particularly useful.

댓글 수: 3

Royi Avital
Royi Avital 2020년 4월 29일
Could you please link to a link which is not version dependent?
Walter Roberson
Walter Roberson 2020년 4월 29일
Yes, that is the current version. However, that is version dependent. A version-independent page can only really work if there has never ever been any change to the documentation; otherwise the closest you could get would be a documentation page that listed all of the historical differences against the current version (which would be version dependent but in a useful way.)

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

추가 답변 (0개)

카테고리

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

제품

태그

질문:

2012년 7월 25일

댓글:

2020년 4월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by