MATLAB: How to read a .txt file

delimiterfile idformatspectxt

Hi The .txt file is as such
Name Lon Lat
xxxx 12.111 15.1122
It continues for seven rows. How to read this file using fileID and formatspec ?? I want to read these 3 columns and write into 3 separate data arrays. Please help.

Best Answer

fid = fopen('filename.txt','rt');
C = textscan(fid,'%s%f%f','headerlines',1);
fclose(fid);
name = C{1};
LatN = C{2};
LonN = C{3};
Related Question