Use a combination of FPRINTF and CPRINTF, without outputting CR/LF before the "final" end of line.
>> fprintf('This is a ') ; cprintf('_red', 'colorful ') ; fprintf('example!\n') ;
but be aware that CPRINTF is rather slow.
>> tic ; for k = 1:1e2, fprintf('.') ; end ; fprintf('\n') ; toc
...
Elapsed time is 0.001758 seconds.
>> tic ; for k = 1:1e2, cprintf('_red', '.') ; end ; fprintf('\n') ; toc
...
Elapsed time is 1.458687 seconds.
Best Answer