Clear Filters
Clear Filters

Concatenate cell and integer array horizontally

1 view (last 30 days)
Hi all,
I have a structure (Group1_KOs), that contains a field (Behaviours) that are m*7 cell arrays. I have created a second structure (EventDuration) that consists of one field (Behaviours), which are m*1 integer arrays. I would like to concatenate these such that Group1_KOs.Behaviours is a m*8 cell array. I have tried coding it as follows, but to no avail:
Any help would be appreciated
for k= 1:size(Group1_KOs,2)
Group1_KOs(k).Behaviours = [Group1_KOs(k).Behaviours EventDuration(k).Behaviours];

Accepted Answer

Stephen23 on 15 Apr 2020
Edited: Stephen23 on 15 Apr 2020
You will need to convert the integer array into a cell array, e.g. using num2cell:
for k = 1:size(Group1_KOs,2)
Group1_KOs(k).Behaviours = [Group1_KOs(k).Behaviours,num2cell(EventDuration(k).Behaviours)];
end % ^^^^^^^^^ ^

More Answers (0)


Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!