how to combine a cell and a double

10 views (last 30 days)
Hi,
I have a cell array 144x1 (imgList2) and a double 144x4 (KeyLocs). I would like to put those 144x4 (KeyLocs) arrays into 144x1 (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

Accepted Answer

Guillaume
Guillaume on 29 Jun 2015
Edited: Guillaume on 29 Jun 2015
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)]
  1 Comment
Nilgun Turkileri
Nilgun Turkileri on 29 Jun 2015
Thank you so much! That was easier than I expected. Cheers!

Sign in to comment.

More Answers (0)

Categories

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!