Hi, I'm trying to read the raw data from a txt file and making plot.The codes read the file as an array of strings. Then transfer string to num and get the year data. But it shows that the index exceeds matrix dimensions at line 9. And I don't know why z is a 1×1 cell. Shouldn't it be an array? By the way, I don't know if my code work for the plot. The txt file is attached, any comment is helpful. Thanks.
filename = input('Please enter the file name: '); fid01 = fopen(filename,'r'); for i = 14 : 66 line = fgets(fid01); z = strread(line,'%s'); year = str2num(z{1}); for j = 2:13 monthly_entry = str2num(z{j}); if (monthly_entry == -99.99) monthly_entry = [ ]; x = year + 1/12; y = monthly_entry; end end endplot( x, y)
Best Answer