MATLAB: Textscan Issue (Reading file that starts with text and finishes with numerical data)

textscan

Hi, I am using textscan to read over a dataset of .asc files.
# Phase = a
# Cycle = 002
# Pass = 0015
# Equ_time = 244739511.104659 (03-Oct-1992 15:11:51)
# Equ_lon = 261.498950
# Original = GDR-M of 1996-151T07:29:48
# Col 1 = time rel. to equator passage [s]
# Col 2 = latitude [degrees_north]
# Col 3 = longitude [degrees_east]
# Col 4 = sea level anomaly [m]
910.373608 43.419923 -77.587550 74.905
911.452414 43.467716 -77.547929 74.825
912.531232 43.515492 -77.508239 74.783
913.610062 43.563251 -77.468479 74.770
914.688903 43.610993 -77.428649 74.781
915.767758 43.658717 -77.388748 74.785
916.846623 43.706425 -77.348776 74.764
917.925499 43.754115 -77.308734 74.792
919.004389 43.801789 -77.268620 74.815
I want textscan to not read the lines of text and to instead write the columns of data to a matrix C as I attempted here.
fid = fopen('txp0015c002.asc');
C = textscan(fid,'%f %f %f %f', 'delimiter', '#');
fclose(fid);
disp(C);
Instead, I get a 1×4 matrix of empty values. Please help!!

Best Answer

I would use:
C = textscan(fid,'%f %f %f %f', 'HeaderLines',10, 'delimiter', '\n', 'CollectOutput');