Matlab: how to write more than one time in the same cell in cell array?

Sunday, May 11, 2014

How to write more than one time in the same cell in cell array in Matlab? For example, if I have a for loop that writes {1} in cell I want to loop again then write 2 beside 1 I don't want to overwrite the {1} so the cell will be {1,2} and so on? This is my code but it is not working:



hop1=cell(5,5);
for i=1:5
for j=1:5
if direct{j,i}==0
for s=1:5
if direct{j,s}==1

if direct{s,i}==1
temp= hop1{j,i};
hop1{j,i}=[temp; userCon.ID(s)];
end
end

end
end
end
end


In this part : temp= hop1{j,i}; hop1{j,i}=[temp; userCon.ID(s)]; end I thought that this will make me able to write more than one element in the same cell but it didn't work.







http://ift.tt/1iDpYiN