MATLAB: Trying to convert cell to array when cells have range of values

cellcell arraysdouble

I have a 1×1000 cell that I am trying to convert to an array so I can easily copy out all the columns and rows of data. Unfortunately, in each cell there are doubles that vary in length (80×1 double, 81×1 double, 79×1 double) I tried cell2mat but since they are all different lengths that did not work.
What if any function may do what I am trying to do and fill in the void spaces with placeholders that are not 0?
Thank you in advance.

Best Answer

This should do the trick. It assumes array indexing is possible.
a={[1 2 3]',[1 1]',[1 2 3 4 5 6]'};
maxlen=max(cellfun('length',a));
clc
a2=cellfun(@extend_to_maxlength,...
a,repmat({maxlen},size(a)),...
'UniformOutput',false);
a2=cell2mat(a2);
function x=extend_to_maxlength(x,maxlen)
if numel(x)<maxlen
x(maxlen)=0;
end
end