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!