How can I append a new cell onto the end of a Cell Array?

201 次查看(过去 30 天)
Lets say I have a cell array C, with 1 column of different sized sub arrays (Example below)
C = {1x3 Cell};
{1x5 Cell};
{1x6 Cell};
Now lets say I have a new Cell F, and I want to append it to the end of Cell Array C.
F = {1x8 Cell};
I want to add F to C such that C looks like as follows:
C = {1x3 Cell};
{1x5 Cell};
{1x6 Cell};
{1x8 Cell}; % <--- This is Cell F
I want to do this to add new cells to the end of a primary cell array, without the need for loops. Is there any way to do this simply? I found a workaround by using length(CellArray) for the index position, but was hoping there would be an append() function or something.
  1 个评论
Gali
Gali 2023-1-8
编辑:Gali 2023-1-8
I have similar case with more cell array in Group_1 of about 200cell, Group_2 = 50cell and Group_3 = 100cell. Basically I want to group them in the same place and then I can find the average of certain parameter. This is what I was trying but picking only the Group_1 and Group_2 and find the averages.
G_1 = (G{1,1}); %% string and number 1x150cell --- e.g (200X15 dataset, 500X15dataset, .........)
G_2 = (G{1,2}); %% string and number 1x50cell --- e.g (255X15 dataset, 25X15dataset, .........)
G_3 = (G{1,3}); %% string and number 1x100cell --- e.g (100X15 dataset, 50X15dataset, .........)
G_1_2 = [G_1; G_2];
also use G_1_2 = {G_1; G_2}
I want to combine G_1 and G_2 before calculating the aveage. Why is it working when G_1 and G_2 are numeric.
Thank very much

请先登录,再进行评论。

采纳的回答

James Tursa
James Tursa 2020-4-28
编辑:James Tursa 2020-4-28
If F really is a cell array in the format you list, then just
C(end+1) = F;
If not, then you may have to do this:
C(end+1) = {F};

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by