Yr Mnth LowTemp(°F) HighTemp(°F) Precip(in) 89 Feb 53.8 71.6 2.67 89 Mar 58.5 76.3 2.84 89 Apr 62.4 80.6 1.80 89 May 68.9 86.3 2.85 : (continues with the same pattern unitl the end of the file)
Note that only two digits are used for the year (this was common
practice in the last century). An example file of this format is
provided in temps.txt.zip . (Decompress it to get temps.txt
We are using MATLAB.
Problem 1. Write a program that reads data in this format and creates a new ASCII text file that is equivalent but has the year values converted to be four digit (e.g. 1989). The names of both files should be provided by the user. For example, after being processed by your program, the above data would start with the following lines.
inp2 = input('Enter input filename:','s');
inp3 = input('Enter output filename:','s');
fileID = fopen(inp2, 'r');
fileID2 = fopen(inp3, 'wt');
i = 0;
nline = fgets(fileID);
tline = nline;
fprintf(fileID2,'%s',tline);
tline = fgets(fileID);
nline = strcat('19',tline);
%fprintf(fileID2,'\n');
while ischar(tline)
fprintf(fileID2,'%s\n',nline);
tline = fgets(fileID);
nline = strcat('19',tline);
end
fclose(fileID);
fclose(fileID2);
Yr Mnth LowTemp(°F) HighTemp(°F) Precip(in) 89 Feb 53.8 71.6 2.67 89 Mar 58.5 76.3 2.84 89...