MATLAB: How to combine a cell and a double

cellcombinedouble

Hi,
I have a cell array 144×1 (imgList2) and a double 144×4 (KeyLocs). I would like to put those 144×4 (KeyLocs) arrays into 144×1 (imgList2) as they were the second column of the imgList2.
I have done it before as
for i=1:length(imgList2{1,1}); imgList2{i,1}=imgList{1,1}(i,:); imgList2{i,2}=KeyLocs(i,:); end
but, this does not work now for some reason..It gives me this error: "??? Index exceeds matrix dimensions."
Thank you in advance,
Nil

Best Answer

Don't use a loop, it's going to be slow. num2cell is probably the easiest way of doing what you want:
imgList2 = [imgList2, num2cell(KeyLocs, 2)]