clc clear all close all disp('ABSTRACT') disp(' Example showing the use of a for-loop to read a file.') filen='C:\Documents and Settings\djmille3\Desktop\example1_read.txt'; disp(' ') % INPUTS fh=fopen(filen,'r'); % read line 1 using the file handler varible, fh. a=fgets(fh); % n is the number of operations to conduct n=sscanf(a,'%f'); % preallocating space using a zeros matrix row_sum=zeros(1,n) % using the for-loop to read the lines of the text document for i=1:1:n a=fgets(fh); b=sscanf(a,'%f %f'); row_sum(i)=b(1)+b(2) end