cast from Array to StringArray - C++ API

5 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Software Development Tools 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by