Lets suppose we have a structure v which has variable number of elements in its objects
>> v(1).a = 1:10;
>> v(2).a = 1:20;
>> v(3).a = 1:30;
Now if we want to put it into a cell array we can simply concatenate and we will have a a with 3 cells with in
>> c = {v(1).a,v(2).a,v(3).a}
c =
[1x10 double] [1x20 double] [1x30 double]
and we can access any element within cell by using
c{i}(j)
but now for example if i have to fill the same array dynamically in a for loop
c = v(1).a
for i= 2:numel(v)
c= {c ,v(i).a};
end
for the first 2 iterations it works in the same way as c = {v(1).a,v(2).a}
c =
[1x10 double] [1x20 double]
but after the 3rd iteration it converts the first two array into a cell with a cell
c =
{1x2 cell} [1x30 double]
how can avoid this ? and create a cell of array instead, like the first case, using a for loop