フィルターのクリア

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 Center および File ExchangeStructures についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by