Blog Archive

Monday, November 22, 2010

Matlab text file read example and tutorial

function myFileRW(input)


% 确定此文件有多少行(numline)
fid = fopen(input,'r');
numline = 0;
disp('total line')
fid
while feof(fid) ~= 1
currentLine = fgetl(fid);
numline = numline + 1;
end
fclose(fid);





fid = fopen(input,'r');
numline = 0;
while feof(fid) ~= 1
currentLine = fgetl(fid);
sprintf('Show the line of NO. %d',numline)
currentLine
numline = numline + 1;
end
fclose(fid);

No comments:

Post a Comment