MATLAB: How to make the vectors length in the cell array equal

features

hi all, I've a cell array which contains vectors with different length.I want to make the vectors length with maximum length of vector.how to do that.Pls help…

Best Answer

example:
Let A - your cell array
A = arrayfun(@(x)randi(45,randi([3 8]),1),1:10,'un',0);
n = cellfun(@numel,A);
m = max(n);
out = cellfun(@(x,y)[x(:);zeros(max(n)-y,1)],A,num2cell(n),'un',0);