Reputation: 5202
Hi I have a cell array which is called vector
, with dimensions 69083x2 , now i want to reshape this cell array to 3212762x2, but reshape(vector,3212762,2) does not work. I get this error:
To RESHAPE the number of elements must not change.
Can anyone tell me how I can do this ?
Upvotes: 0
Views: 1980
Reputation: 14735
Do you mean you wish to make the cell array larger? reshape
is to store the same elements in a different 'shape', for eg., a 3x2 cell array as a 6x1 cell array - note that the total number of elements remains 6 in both cases.
If you wish to enlarge the cell array, just assign something to the last element of the enlarged cell array like so:
vector(3212762, 2) = {[]}
Now vector
would be of size 3212762x2.
Upvotes: 3
Reputation: 314
Just like sundar mentioned
vector(3212762, 2) = 0
will give you 3212762x2 matrix with the new rows assigned to 0.
Upvotes: -2