0
votes

I have a 73 x 1 cell, each of those cells contains a 16 x 1 cell and each of those cells is an image. Is there an easy way I can convert this into one big array of cells containing only the images? Many thanks.

enter image description here

1
What is the shape of your final big cell array? - Dan
@dan I've added a picture. That's the 73 x 1 cell array I have at the moment. Basically I'd like to expand that into either a 73 x 16 array (by expanding out out 16 x 1 array) or just one big row/column of every cell so I can access images easily. - Mike Miller
Have you looked at cell2mat? - eigenchris
@eigenchris unfortunatley seems to turn the 16 x 1 arrays into one big matrix which isn't ideal - I'd like to keep the images separate. - Mike Miller

1 Answers

3
votes

If C is your cell, use B = [C{:}] to create a 16×73 cell B with every column one of your original 16×1 cell elements. This works, because C{:} accesses every element in cell C and the brackets ([ ]) group all these elements into one array again. This is possible, because every element in C is of the same type and size.

Use B = B(:) to get a 1168×1 cell (73*16=1168), if you want. Either way, B{n} accesses the n-th image.