It's pretty unlikely that anyone can help with just that information. Attach a SMALL example of something like your files, show a small example of what you are starting with and what you want to end up with, and where in your code the error is coming from.
In any case, this
fill1 = randi(10, [y,1]);
fill2 = randi(10, [y,1]);
fill1(1:y) = nan;
fill2(1:y) = nan;
T1 = array2table(fill1);
T2 = array2table(fill2);
T_new = [T, T1, T2];
is much too complicated. If ytou want to add two all-NaN column vectors to T, just assign nan(y,1) to T.fill1 etc. Just like what you did in the isequal(x,22) case.