cast from Array to StringArray - C++ API

2 visualizaciones (últimos 30 días)
MelKor
MelKor el 1 de Jun. de 2018
Editada: James Tursa el 1 de Jun. de 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

Respuestas (0)

Categorías

Más información sobre Deploy to C++ Applications Using MATLAB Data API (C++11) en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by