MATLAB: How to make each vector of equal size in a cell by adding NAN

cell arrayvector size;

A cell with row vectors in it(Vectors are of 2 sizes: either 1×2544 or 1×2545). To process the data, It needs to have vectors of equal size . Is there any code which could add NaN to the the short vectors (1×2544) and make them 1×2545?
Thanks

Best Answer

c = {rand(1, 2544); rand(1, 2545); rand(1, 2544)} %demo data
maxlength = max(cellfun(@numel, c));
newc = cellfun(@(v) [v, nan(1, maxlength-numel(v))], c, 'UniformOutput', false)