MATLAB: How to delete file columns

deletefiletext file

I've the file below, and I would like delete the columns 2, 3 and 4. And If It's possible, put a header file "In Temp" in column 1, and "Time" in column 5.
19.99475 0.00000000 1 1 01.00.00
19.93432 0.00000000 1 1 02.00.00
19.95047 0.00000000 1 1 03.00.00
19.94692 0.00000000 1 1 04.00.00
19.94284 0.00000000 1 1 05.00.00
19.93054 0.00000000 1 1 06.00.00
19.91392 0.00000000 1 1 07.00.00
19.91620 0.00000000 1 1 08.00.00
20.07122 0.00000000 1 1 09.00.00
30.74621 0.00000000 1 1 10.00.00
33.82622 0.00000000 1 1 11.00.00
24.26688 0.00000000 1 1 12.00.00
25.74946 0.00000000 1 1 13.00.00
27.38718 0.00000000 1 1 14.00.00
26.84582 0.00000000 1 1 15.00.00
26.75560 0.00000000 1 1 16.00.00
26.99042 0.00000000 1 1 17.00.00
28.62772 0.00000000 1 1 18.00.00
29.07095 0.00000000 1 1 19.00.00
29.41968 0.00000000 1 1 20.00.00
29.66041 0.00000000 1 1 21.00.00
29.82444 0.00000000 1 1 22.00.00
29.97447 0.00000000 1 1 23.00.00
30.05386 0.00000000 1 2 00.00.00
30.17622 0.00000000 1 2 01.00.00
26.37835 0.00000000 1 2 02.00.00
25.70272 0.00000000 1 2 03.00.00
...

Best Answer

fid = fopen('YourFile.txt', 'rt');
datacell = textscan(fid, '%s%*s%*s%*s%s', 'CollectOutput', true);
fclose(fid);
data_to_print = [{'ln Temp', 'Time'}; datacell{1}] .'; %transpose is important
fmt = '%8s%15s\n';
fid = fopen('NewFile.txt', 'wt');
fprintf(fid, fmt, data_to_print{:});
fclose(fid);