cast from Array to StringArray - C++ API

2 vues (au cours des 30 derniers jours)
MelKor
MelKor le 1 Juin 2018
Modifié(e) : James Tursa le 1 Juin 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

Réponses (0)

Catégories

En savoir plus sur Software Development Tools dans Help Center et File Exchange

Tags

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by