Linear indexing for multi-dimensional struct array in C++ API
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Call C++ from MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!