MATLAB: Textscan only reading 1 line (headerline + 1st line)

MATLAB

Code:
filename='virtual_measurements.dat';
fid=fopen(filename);
A=textscan(fid,'%16c %f %f %f %f %f','HeaderLines',1);
Data:
date [yyyy-mm-dd HH:MM] J [mm/h] Q [mm/h] ET [mm/h] Cin [-] wi [-] measC_Q [-]
2012-09-30 00:00 0.00 0.04 0.00 50.00 0.38 -999.00
2012-09-30 01:00 0.00 0.04 0.00 50.00 0.38 -999.00
2012-09-30 02:00 0.00 0.04 0.00 50.00 0.38 -999.00
2012-09-30 03:00 0.00 0.04 0.00 50.00 0.38 -999.00

Best Answer

Your count for the floats is off by one-- there are six, not five. Either read the whole file and just discard any you don't want or use the '*' to ignore a field.
You'll also have better luck with
fmt=['%s%s' repmat('%f',1,6)];
to return the date fields as strings than character. BUT, the better yet would be to use the new(ish) '%D' date conversion field descriptor and return datetime values directly...
>> fmt=['%{yyyy-MM-dd}D' '%{HH:mm}D' repmat('%f',1,6)];
>> frewind(fid)
>> data=textscan(fid,fmt,'collectoutput',1,'headerlines',1)
data =
[4x1 datetime] [4x1 datetime] [4x6 double]
>>