convert MATLAB cell type to c++

怎甘沉沦 提交于 2019-12-04 08:15:31

That's because 'cell' is not really a type - it is a placeholder for anything you want to place in it. The closest thing I can think of in languages such as C# and Python is a 'tuple', which intrinsically can contain anonymous types.

Since C++ does not have a built-in tuple type, I suggest you take a look at Boost, which is a very comprehensive, mature and open-source library for practically anything you need in C++. Under Boost, take a look at the Fusion library, or if you require something not simpler, at the Tuple library.

EDIT as Matt mensioned below, as of TR1, tuples are part of the C++ standard library. See Matt's link here.

Your cell data will likely translate fairly well into a C++ object. I would recommend you examine what your cells contain and see if you could represent it as a class. Then you would be able to create vectors/arrays/matrices of your objects and have them treated similar to cells in MATLAB.

Armadillo has field class!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!