MATLAB: Is there a function in MATLAB 7.0 (R14) that will allow me to read a text data file with multiple header rows interspersed with data

MATLAB

I have a text file that is set up as follows
H1 H2 H3 H4
1 2 3 4
5 6 7 8
H5 H6 H7 H8
9 10 11 12
13 14 15 16
17 18 19 20
My objective is to import all the numeric data discarding any rows containing text headers.

Best Answer

The following code snippet illustrates how this can be achieved
fid = fopen('mydata.txt', 'r');
d = {};
while ~feof(fid)
fgetl(fid); % header row
c = textscan(fid, '%d %d %d %d'); %Four data columns.
d = vertcat(d, c);
%Alternatively, d = [d; c]
end;
fclose(fid);
For information on functions used in the example execute the following command at the MATLAB prompt
doc <function_name>