Getting fieldnames from mwArray struct
조회 수: 8 (최근 30일)
이전 댓글 표시
Is there any way to extract all the field names from a struct stored in an mwArray? Similar to the fieldnames() command inside matlab
댓글 수: 0
답변 (1개)
Co Melissant
2014년 8월 20일
number of fields can be obtained using "NumberOfFields()":
const char* fields[] = {"a", "b", "c"};
mwArray a(2, 2, 3, fields);
int n = a.NumberOfFields();
individual field names can then be obtained using "GetFieldName(id)"
const char* fields[] = {"a", "b", "c"};
mwArray a(2, 2, 3, fields);
mwString tempname = a.GetFieldName(1);
const char* name = (const char*)tempname;
So using a loop all names you can get all names. Not aware of a simpler solution...
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Deploy to C++ Applications Using mwArray API (C++03)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!