Filter löschen
Filter löschen

Storing different size cell array into a cell array.

24 Ansichten (letzte 30 Tage)
ANURAG DEEPAK
ANURAG DEEPAK am 9 Nov. 2021
Kommentiert: ANURAG DEEPAK am 10 Nov. 2021
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.

Akzeptierte Antwort

Jan
Jan am 9 Nov. 2021
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;

Weitere Antworten (0)

Kategorien

Mehr zu Structures 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!

Translated by