23

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?

2 Answers 2

36

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) = {[]}
Sign up to request clarification or add additional context in comments.

2 Comments

Man, that was quick... +1
Quick and useful reply! Thank you.
13

Adding to Dan's answer, in case you have a cell that is not a single dimension cell, you might want to add a full row, for example. In that case, access the cell as an array using ().

>> c = { 1, 'a'; 2, 'b'}

c = 

    [1]    'a'
    [2]    'b'

>> c(end+1,:) = {3,'c'}

c = 

    [1]    'a'
    [2]    'b'
    [3]    'c'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.