Linear indexing for multi-dimensional struct array in C++ API
이전 댓글 표시
In plain MATLAB I can use the following code and ignore the actual dimensions:
s = repmat(struct('exampleField',1),[2,3,4,5]);
for ii = 1:numel(s)
disp(s(ii).exampleField)
end
However, in the C++ API, I can't use the linear indexing as the following code fails with the error: "Not enough indices provided."
void func(matlab::data::StructArray s){
for (size_t ii = 0; ii < s.getNumberOfElements(); ++ii)
std::cout << s[ii][std::string("exampleField")] << std::endl;
}
Is there a way to still use linear indexing? Without linear indexing generic code development gets nearly impossible.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!