Borrar filtros
Borrar filtros

Storing different size cell array into a cell array.

24 visualizaciones (últimos 30 días)
ANURAG DEEPAK
ANURAG DEEPAK el 9 de Nov. de 2021
Comentada: ANURAG DEEPAK el 10 de Nov. de 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.

Respuesta aceptada

Jan
Jan el 9 de Nov. de 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;
  1 comentario
ANURAG DEEPAK
ANURAG DEEPAK el 10 de Nov. de 2021
Thanks Sir..... it worked by copying only the existing elements.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by