How do I go about adding a new row to a cell array? For example, if i have a 3x4 cell array and then i want to add a new row so it is a 4x4 cell array. It is probably really simple and i just can't get it... haha
Thanks,
Naruto
No problem! (And welcome!) I don't have access to MATLAB at the moment, but I found this reference.
"MATLAB expands the size of the cell array with each assignment statement... If you assign data to a cell that is outside the dimensions of the current array, MATLAB automatically expands the array to include the subscripts you specify. It fills any intervening cells with empty matrices."
First some background... bananas is a 3x4 cell array and i want to add a new row with 4 columns so it becomes a 4x4.
So I add this to it using this code:
bananas = {bananas;{1, 2, 3, 4}}
But when i look at the info of the cell array it tells me that is is just a 3x4 on top of a 1 x 4. Is there anyway to get as one big cell array that is 4x4?
To be honest I have never used MATLAB (it costs $ and I haven't had access); however, I know several programming languages and some CAS's.. so going purely off of documentation, I'd say to try
If that doesn't work, someone who's actually used MATLAB should notice this thread eventually and be able to tell you.Code:bananas(4,1) = { [] };
I read some more.. try
and if this works, there should be no need to useCode:bananas(4,1:4) = {1, 2, 3, 4};
unless you want the fourth row to be empty.Code:bananas(4,1) = { [] };
EDIT: You could try this too
This might be valid short-hand.Code:bananas(4,:) = {1, 2, 3, 4};