clc clear all close all disp('ABSTRACT') disp(' Example showing how to read data from a file.') disp(' ') % INPUTS disp('INPUTS') filen='C:\Documents and Settings\djmille3\Desktop\example1_read.txt'; % READING THE FILE fh=fopen(filen,'r'); % change the 'r' to 'w' to write % change the 'r' to 'a' to append. % read line 1 of text file using fh a=fgets(fh); n=sscanf(a,'%f'); % read line 2 of text file using fh a=fgets(fh); % read entire line 2 of text file. b=sscanf(a,'%f %f'); % store in matrix [b] using %f format. row_sum(1)=b(1)+b(2) % conducting operation specified % read line 3 of text file using fh a=fgets(fh); % read entire line 3 of text file. b=sscanf(a,'%f %f'); % store in matrix [b] using %f format. row_sum(2)=b(1)+b(2) % conducting operation specified % read line 4 of text file using fh a=fgets(fh); % read entire line 4 of text file. b=sscanf(a,'%f %f'); % store in matrix [b] using %f format. row_sum(3)=b(1)+b(2) % conducting operation specified % read line 5 of text file using fh a=fgets(fh); % read entire line 5 of text file. b=sscanf(a,'%f %f'); % store in matrix [b] using %f format. row_sum(4)=b(1)+b(2) % conducting operation specified