利用循环读取数据

fid = fopen("2014temps.txt");

% START OF LOOP
while ~feof(fid)
    % Read header line with station information
    s = split(fgetl(fid));
    snum = str2double(s{1});
    nlines = str2double(s{2});
    
    % Read in the observation times
    headers = split(fgetl(fid));
    ncols = numel(headers);
    fmtStr = repmat('%f',1,ncols);
    
    % Read the current block of data
    data = textscan(fid,[ '%{yyyyMMdd}D' fmtStr ],nlines,"TreatAsEmpty","*");
    
    % Assemble into table
    stn = timetable(data{:},'VariableNames',headers);
        
    % Create plot
    figure;
    stackedplot(stn);
    title("Station Number " + snum)
    
    % Read to the end of the line
    fgetl(fid); 

% END OF LOOP
end
fclose(fid);


2014temps.txt

941190 12

020000 023000 050000 053000 080000 083000 110000 113000 140000 143000 170000 173000 200000 203000 230000 233000

20140101 32.50 32.50 32.20 32.20 26.70 26.70 26.60 26.60 26.40 26.40 25.70 25.70 25.20 25.20 30.30 30.30

20140201 26.10 26.10 26.90 26.90 27.80 27.80 27.70 27.70 24.30 24.30 26.60 26.60 26.80 26.80 29.10 29.10

20140301 32.30 32.30 31.80 31.80 30.60 30.60 25.90 25.90 24.20 24.20 24.10 24.10 23.40 23.40 28.60 28.60

20140401 33.50 33.50 27.70 27.70 28.70 28.70 26.10 26.10 26.40 26.40 25.80 25.80 25.60 25.60 29.90 29.90

20140501 34.00 34.00 34.50 34.50 29.40 29.40 25.60 25.60 24.60 24.60 24.40 24.40 24.40 24.40 28.80 28.80

20140601 32.90 32.90 33.60 33.60 29.30 29.30 24.40 24.40 23.40 23.40 23.50 23.50 24.20 24.20 27.20 27.20

20140701 26.40 26.40 29.20 29.20 24.40 24.40 19.40 19.40 17.10 17.10 16.70 16.70 16.00 16.00 22.20 22.20

20140801 31.40 31.40 33.30 33.30 27.60 27.60 24.20 24.20 22.40 22.40 22.40 22.40 21.70 21.70 26.00 26.00

20140901 31.90 31.90 32.20 32.20 27.20 27.20 22.90 22.90 20.40 20.40 19.10 19.10 18.30 18.30 23.10 23.10

20141001 33.10 33.10 32.20 32.20 28.60 28.60 25.10 25.10 23.60 23.60 22.60 22.60 20.60 20.60 30.00 30.00

20141101 34.90 34.90 37.30 37.30 31.20 31.20 25.30 25.30 24.30 24.30 22.70 22.70 21.50 21.50 28.10 28.10

20141201 27.80 27.80 30.00 30.00 27.40 27.40 26.30 26.30 26.50 26.50 27.00 27.00 26.10 26.10 31.10 31.10

941280 24

020000 050000 080000 110000 140000 170000 200000 230000

20140101 32.90 36.10 35.50 29.50 27.40 26.30 25.90 29.90

20140115 26.10 25.80 26.20 24.00 23.80 24.90 25.00 25.60

20140201 29.10 30.20 29.20 27.20 26.20 25.90 24.30 25.90

20140215 31.40 33.10 31.90 27.60 25.80 25.40 25.70 26.80

20140301 30.60 30.20 26.50 25.30 25.50 24.50 24.10 27.50

20140315 32.10 33.50 33.60 27.00 26.50 24.40 23.60 28.20

20140401 33.30 35.30 34.50 28.00 26.10 25.20 24.20 29.00

20140415 32.40 34.10 32.10 23.40 24.00 20.20 19.20 25.60

20140501 32.80 34.10 33.40 27.70 25.70 23.30 22.40 25.90

20140515 32.70 33.00 30.10 23.20 23.40 24.10 21.70 26.70

20140601 30.90 32.70 31.00 25.00 23.60 21.90 21.20 24.60

20140615 25.60 26.60 23.50 17.40 14.90 14.50 12.00 17.70

20140701 24.00 26.70 23.60 15.80 13.90 12.20 11.70 15.40

20140715 29.80 33.30 30.80 23.50 21.80 18.10 16.90 21.30

20140801 31.10 33.30 31.50 25.00 24.00 21.40 19.30 25.00

20140815 25.10 28.50 26.40 16.50 16.20 12.40 9.60 18.00

20140901 29.80 33.30 31.00 21.70 20.10 14.80 13.40 22.00

20140915 32.50 34.90 33.20 26.10 23.40 21.90 19.40 25.50

20141001 34.00 37.60 36.50 27.80 25.40 23.00 21.60 27.70

20141015 34.70 36.80 36.00 29.50 24.70 22.20 22.10 30.00

20141101 36.90 40.20 38.20 31.10 27.50 25.80 23.80 29.90

20141115 31.90 32.30 32.60 28.20 25.70 24.70 24.80 30.80

20141201 32.60 34.70 27.90 25.00 25.00 25.20 25.30 29.60

20141215 34.20 36.40 33.20 26.80 26.30 25.70 25.90 30.80

941340 55

230000

20140101 31.00

20140108 31.00

20140115 27.00

20140122 25.50

20140129 27.50

20140202 29.50

20140209 29.80

20140216 27.60

20140302 29.70

20140309 24.50

20140316 28.30

20140330 28.70

20140401 28.80

20140408 28.00

20140415 29.80

20140422 28.30

20140429 28.40

20140501 28.40

20140508 27.30

20140515 26.00

20140522 26.60

20140529 27.40

20140601 27.40

20140608 23.90

20140615 21.90

20140622 23.00

20140629 22.20

20140701 22.20

20140708 24.20

20140715 24.00

20140722 23.10

20140729 25.40

20140801 25.90

20140808 24.80

20140815 24.00

20140822 21.50

20140829 23.00

20140901 24.10

20140908 25.40

20140915 27.00

20140922 26.80

20140929 27.50

20141001 28.20

20141008 28.00

20141015 30.40

20141022 29.30

20141104 30.00

20141111 30.00

20141118 30.50

20141125 31.00

20141201 29.90

20141208 31.00

20141215 31.30

20141222 31.50

20141229 28.50

941320 12

050000 230000 233000

20140101 32.10 30.70 30.70

20140201 28.00 25.60 25.60

20140301 28.00 26.80 26.80

20140401 37.20 30.00 30.00

20140501 35.50 27.90 27.90

20140601 * 25.20 25.20

20140701 26.60 14.70 14.70

20140801 34.00 24.60 24.60

20140901 33.00 22.80 22.80

20141001 37.50 28.50 28.50

20141101 40.50 31.40 31.40

20141201 37.00 26.70 26.70