Is it possible to insert multidimensional arrays within table entries?
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
deathtime
am 14 Apr. 2023
Beantwortet: the cyclist
am 14 Apr. 2023
For example: I want to create a table with 5 rows and 2 columns. The first column is just 5 rows of doubles. Can I insert a 3x3x2 array into every row of the second column?
1 Kommentar
Dyuman Joshi
am 14 Apr. 2023
Bearbeitet: Dyuman Joshi
am 14 Apr. 2023
It is possible, but technically it's a 1x1 cell array which contains the 3x3x2 double array -
data1 = rand(5, 1);
data2 = repmat({rand(3,3,2)}, 5, 1);
y=table(data1, data2)
Akzeptierte Antwort
the cyclist
am 14 Apr. 2023
I don't think an element of table can be a mutli-dimensional array, but it can be a cell that holds a multidimensional array:
% Create a cell array that will be converted to a table
c = {1,rand(3,3,2);
2,rand(3,3,2);
3,rand(3,3,2);
4,rand(3,3,2);
5,rand(3,3,2)
};
% Convert to table
t = cell2table(c)
% Contents of t(1,2) is a cell array
t{1,2}
% Contents of that cell is the 3,3,2 array
t{1,2}{:}
I'm therefore not sure if a table would be the most appropriate way to store these data, as opposed to a cell array directly.
(But, I could be wrong about a more direct way to store the array.)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!