The first version in your question doesn't work because "names" contain 3 VariableNames that are all "Bin1" so when you assign the values within the loop, the first iteration assigns Bin1 to the table but subsequent iterations overwrite that column since you're writing to the same variable name.
The second version of your question avoids that problem but naming the columns differently.
You can create that table with the 3 lines of code below.
SelectNewVectorCell = {[1;2;3;4;5;6;9;88], [11;22;23;25;66;88], [33;55;66;7;8;9]};
maxNumRow = max(cellfun(@(c) numel(c), SelectNewVectorCell));
mPad = cell2mat(cellfun(@(c){padarray(c,[maxNumRow-numel(c),0],NaN,'Post')},SelectNewVectorCell));
R = array2table(mPad, 'VariableNames', compose('Bin%d',1:size(mPad,2)));
Result
R =
8×3 table
Bin1 Bin2 Bin3
____ ____ ____
1 11 33
2 22 55
3 23 66
4 25 7
5 66 8
6 88 9
9 NaN NaN
88 NaN NaN
Best Answer