Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 402
nik-OS Avatar asked Feb 03 '15 12:02

nik-OS


People also ask

How do you add an element to a cell array in Matlab?

% Create a new cell array. ca % Display in command window. newStuff = rand(2); % Create some new data. % Prepend it before cell #1, and show resulting array in the command window.

How do you add an array to a cell?

C = num2cell( A ) converts array A into cell array C by placing each element of A into a separate cell in C . The num2cell function converts an array that has any data type—even a nonnumeric type.


1 Answers

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) = {[]} 
like image 116
Dan Avatar answered Nov 09 '22 23:11

Dan