Hello Dinouk,
Well, firstly, you're using cell arrays in your code, but you mention matrix in the title. Since you're working with characters, I would continue to use cell arrays.
Your description of the problem is a little hazy, but if you want to insert NaN values in between the sequence, you could simply use a for loop and indexing to get the output -
for i=4:4:28 % This loop work for this specific case, generalize it for other cases
T = {T{1:i-1}, 'NaN', T{i:end}}; % Use indexing to add NaN value in every fourth index
end
This is a simpler approach of the many others to the problem that you have described. The output would be a [1x28] cell array.
Hope this helps!