v = ""; for i = 1:10 v = sprintf("%s%d", v, i); if ( mod(i, 5) == 0 ) disp(v) v = ""; continue endif v = sprintf("%s, ", v); endfor