2012-10-22 83 views

回答

3
fid = fopen('dat.txt'); 

line = fgetl(fid); 

% if you want everything on the same axis, set it up here 
axis([0,20,-10,10]) 
hold all  

while ischar(line) 
    yy = str2num(line); 
    xx = 1:length(yy); 
    plot(xx,yy) 
    line = fgetl(fid); 
end 
hold off 

fclose(fid); 

注意FEOF()不符合fgetl()那麼好,看here