A set of data files named “exfile1.dat”, “exfile2.dat”, etc. has been created by a series of experiments. It is not known exactly how many there are, but the files are numbered sequentially with integers beginning with 1
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:9| Question number:11.9
All Answers
total answers (1)
Ch9Ex11.m
sumlines = 0;
i = 1;
filename = 'exfile1.dat';
fid = fopen(filename);
while fid ~= -1
while ~feof(fid)
aline = fgetl(fid);
sumlines = sumlines + 1;
end
i = i + 1;
filename = sprintf('exfile%d.dat', i);
fid = fopen(filename);
end
fprintf('There were %d lines in the files\n', sumlines)
fclose('all');
need an explanation for this answer? contact us directly to get an explanation for this answer