Storing different size cell array into a cell array.

20 次查看(过去 30 天)
Is there a way to store different size cell array into a seperate cell array (V). For example, the first row of V contain 6 cell arrays, while other rows may contain 5 or 4 cell arrays in an row of V.
The V cell array is shown in the attached file. In this, i am getting an error because the third row has 5 cell arrays while the others have 6 cell arrays.

采纳的回答

Jan
Jan 2021-11-9
Either copy only the existing elements and let the others be []:
C = cell(24, 6);
A = cell(1, 6); % Some test data
A(:) = {rand(1,13)};
B = cell(1, 3); % Some test data
B(:) = {rand(1,13)};
C(1, 1:numel(A)) = A;
C(2, 1:numel(B)) = B;
Think twice, if the data structure is efficient. Storing 6 vectors of the same length is more efficient in a matrix, than in a cell of vectors. Less clutter:
A = rand(6,13);
B = rand(5,13);
C[1} = A;
C{2} = B;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by