필터 지우기
필터 지우기

Storing different size cell array into a cell array.

조회 수: 24 (최근 30일)
ANURAG DEEPAK
ANURAG DEEPAK 2021년 11월 9일
댓글: ANURAG DEEPAK 2021년 11월 10일
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;
  댓글 수: 1
ANURAG DEEPAK
ANURAG DEEPAK 2021년 11월 10일
Thanks Sir..... it worked by copying only the existing elements.

댓글을 달려면 로그인하십시오.

추가 답변 (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