cast from Array to StringArray - C++ API
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to list all the variables in workspace through C++, for that I'm using feval and "who" function to do it. As I can read in the documentation, the result of the feval function is an Array type, and indeed I can get an Array of type CELL with the correct number of elements, but I have not been able to cast the result to an string/u16string type, please share an example to do it.
matlab::data::ArrayFactory factory;
matlab::data::Array const argArray = factory.createCharArray("");
matlab::data::Array results;
try{
results = matlabPtr->feval(matlab::engine::convertUTF8StringToUTF16String("who"), argArray);
}
catch (matlab::execution::MATLABException &e) {
std::cout << e.what();
}
matlab::data::ArrayDimensions dimensions = results.getDimensions();
matlab::data::ArrayType type = results.getType();
I tried all I figure out, from using the native template of feval in the way feval<std::u16string> up to casting the Arry to CellArray and there to StringArray and nothing.
Thanks in advance.
JP
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Software Development Tools finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!