I can preallocate the contents of a usual matrix/vector/array with
giving the result:
This way of reaching each element in an array by typing 1:8 is one of the very useful features of MatLab.
But can I do the same to a cell array? For example:
data = cell(1,8)
data{1:8} = NaN(3,5)
The NaN(3,5) creates a matrix full of NaN values. So, here I first allocate memory for 8 cells in the cell array and then I wish to reach each of these 8 cells by writing data{1:8} and add a NaN-matrix in each of them.
This does not work but gives me:
Apparently the 1:8 syntax does not work inside curly brackets.
So, what is the method for preallocating the content of each cell in a cell array, when they are must simply get the same size and content? Can I not avoid a for loop?