I don't think there's anything wrong with your format string specifically.
Try pulling in the lines individually with fgetl
or similar and just check that there's nothing you weren't expecting in the file. For example - your code seems to work for me but I can replicate your error by putting an additional blank line at the start of the file, which causes textscan
to try and read the second header line as a line of data (and fail inelegantly). That particular error can be removed by increasing the value of HeaderLines
.
fid = fopen('test.txt');
fgetl(fid) % repeat until you see your first line of data