Concatenate cell and integer array horizontally

2 次查看(过去 30 天)
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];
end

采纳的回答

Stephen23
Stephen23 2020-4-15
编辑:Stephen23 2020-4-15
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 % ^^^^^^^^^ ^

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by