cast from Array to StringArray - C++ API

1 visualizzazione (ultimi 30 giorni)
MelKor
MelKor il 1 Giu 2018
Modificato: James Tursa il 1 Giu 2018
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

Risposte (0)

Categorie

Scopri di più su Software Development Tools in Help Center e File Exchange

Tag

Prodotti


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by