Add a new element to the end of an existing cell array

nik-OS picture nik-OS · Feb 3, 2015 · Viewed 37.8k times · Source

As the title already mentions, how is it possible to add a new cell array 1x1 at the end of an existing cell array, let's call him Q, which is a cell array 1x3256?

Answer

Dan picture Dan · Feb 3, 2015

If you mean adding a single cell to the end (i.e. so your 1-by-3256 cell array becomes a 1-by-3257 cell array) then:

Q{end+1} = []

and you can replace [] with your value directly

Alternatively:

Q(end+1) = {[]}