Reputation: 3
I have a 1x46 cell of different length cells.
I want to zero pad each cell to maximum length cell because I want to apply cell2mat function and in order to apply that I need to make this cell consistent.
But whenever I run my code it gives memory error.
The maximum length is 6691240 i.e there are 6691240 elements in the maximum length cell
The code is as follows
for i=1:numel(X1)
if size(X1{i}) < 6691240
X1{i}(end,6691240)=0;
end
end
Upvotes: 0
Views: 79
Reputation: 991
The way I understand is that each cell is a vector, and the length of each such vector needs to be 6691240. Thus, the code needs to be changed as:
for i=1:length(X1)
if length(X1{i}) < 6691240
X1{i}(6691240)=0;
end
end
Upvotes: 1