MATLAB: Read .txt file with header

1

Hello
I have a problem to read a text file into matlab with a header. The text file looks like this : http://web.gvdnet.dk/GVD002139/151.txt
i tried with this – and it works 99%
fid = fopen('151.txt','rt')
datacell = textscan(fid, '%s%s%f%f%f%f%f%f%s%s', 'HeaderLines',9);
fclose(fid);
A1 = mean(datacell{6})
The problems is that the result comes in a single column, but i want the mean of column 4,5,6 and 7 to be on a single row, so i can copy it into another textfile.
Hope anyone can help me. Thanks!

Best Answer

str = urlread('http://web.gvdnet.dk/GVD002139/151.txt');
data = textscan(str, '%s%s%f%f%f%f%f%f%s%s', 'HeaderLines',9,'CollectOutput',1);
mean(data{2})
Related Question