Concatenate cell and integer array horizontally

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Stephen23
Stephen23 il 15 Apr 2020
Modificato: Stephen23 il 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 % ^^^^^^^^^ ^

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by