This bug has been fixed in Release 2007b (R2007b). For previous product releases, read below for any possible workarounds:
Execute the following commands:
fid = fopen('mydata.txt');
data1 = textscan(fid, '%d%d%d', 2, 'headerLines', 1);
data2 = textscan(fid, '%d%d%d', 2, 'headerLines', 2);
The TEXTSCAN function is called once for each set of data, using the 'headerLines' option to skip the header lines.
There is an error in the documentation for TEXTSCAN within the MATLAB Function Reference, concerning the 'headerLines' option. It should read that the value of 'headerLines' is the number of line breaks that are skipped before reading commences.
In the example above, 'headerLines' is set to 2 on the second call to TEXTSCAN because the first call to TEXTSCAN leaves you just before the line break on the third line of "mydata.txt". Moving to the beginning of the next line counts as a header line.