If you don't need individual variable names then I'd probably go with the simplest approach of
data = dlmread('data.txt','',2,0);
If you have missing values or error codes or other weirdness, then use textscan.
If you have Statistics Toolbox, another approach would be to use dataset to import the data as a dataset array:
data = dataset('File','data.txt','headerlines',1);
The downside is that the variable names will be hideous, due to all the non-valid characters. If you wanted to get vaguely fancy (and had some pattern to how to interpret the names), you could use regexp:
fid = fopen('data.txt','rt');
hdr = fgetl(fid);
hdr = regexp(fgetl(fid),'\t','split');
fclose(fid);
hdr = regexprep(hdr,'#','No_');
hdr = regexprep(hdr,'%','Perc_');
hdr = regexprep(hdr,'\W','');
data = dataset('File','data.txt','headerlines',1);
data.Properties.VarNames = hdr
Best Answer