Code covered by the BSD License  

Highlights from
spec file reader

image thumbnail
from spec file reader by Zhang Jiang
Monitor, read, save scans from SPEC files and calculate true reflectivity.

litcount(filename, literal)
function y = litcount(filename, literal)
% Search for number of string matches per line.  

fid = fopen(filename, 'rt');
y = 0;
while feof(fid) == 0
   tline = fgetl(fid);
   matches = findstr(tline, literal);
   num = length(matches);
   if num > 0
      y = y + num;
%      fprintf(1,'%d:%s\n',num,tline);
   end
end
fclose(fid); 

Contact us at files@mathworks.com