先打开文件
[filename,filepath]=uigetfile('*.txt','Select Input file');
file = [filepath filename];
fid = fopen(file,'rt');
if fid == -1
('Error opening the file')
end
%%读取文件
while 1
nextline = fgetl(fid); %读第一行
if ~isstr(nextline), break, end %读到最后跳出
disp(nextline);%这行可以不要
a = sscanf(nextline, ' %f %f ');%读取数据,根据你自己的需要改
end
end