Simplest here is probably just brute force...open an output file, then open each input in succession, copying lines (excepting for the first, without the header lines) from input to the output making in text substitutions need along the way.
You could, of course, read each file into memory, do the clean up there and then write a formatted file. If the input files are truly huge this may be worth doing but the other is quick 'n dirty for reasonable file sizes...
fidO=fopen('output.txt','w');
fid=fopen('input1.txt','r');
while ~feof(fid)
for i=1:2
l=fgets(fid);
fprintf(fidO,'%s',l);
end
l=strrep(fgets(fid),'-99.9',blanks(5));
l=strrep(l,'-99',blanks(3));
fprintf(fidO,'%s',l);
end
fid=fclose(fid);
fid=fopen('input2.txt','r');
for i=1:2, fgets(fid); end
while ~feof(fid)
l=strrep(fgets(fid),'-99.9',blanks(5));
l=strrep(l,'-99',blanks(3));
fprintf(fidO,'%s',l);
end
fclose('all')
clear fid*
You'll note above for just two files I didn't even bother to create the outer loop over them; for more it would be worth doing that refinement.