Search code examples
matlabcell-array

Matlab: adding cell to cell array


Suppose I have a 3x1 cell array:

c = {[1, 2, 3]; [1, 2, 3, 4, 5]; [1, 2]}

I now want to add another array, to make it a 4x1 array. How do I do this? I have tried the following:

c = {c; [1, 2, 3, 4]}

But it then tells me that:

c = {3x1 cell}    [1x3 double]

Whereas I want:

c = {4x1 cell}

What should I do? Thanks.


Solution

  • c=[c; [1, 2, 3, 4]]
    

    or

    c{end+1}= [1, 2, 3, 4]