Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert MATLAB cell type to c++

i'm converting a MATLAB program in c++ using Armadillo for matrix algebra.

i'm stuck on cell type. someone has some hints?

like image 713
nkint Avatar asked Feb 10 '12 18:02

nkint


People also ask

How do I change a cell to an array?

A = cell2mat( C ) converts a cell array into an ordinary array. The elements of the cell array must all contain the same data type, and the resulting array is of that data type. The contents of C must support concatenation into an N-dimensional rectangle.

How do you turn a cell into a table in MATLAB?

T = cell2table( C ) converts the contents of an m -by- n cell array, C , to an m -by- n table, T . Each column of C provides the data contained in a variable of T . To create variable names in the output table, cell2table appends column numbers to the input array name.

What is MATLAB str2double?

X = str2double( str ) converts the text in string str to a double-precision value. In a chart that uses MATLAB® as the action language, str2double returns a complex value.


1 Answers

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.

like image 192
bavaza Avatar answered Oct 22 '22 15:10

bavaza