%discurve.m

clear;
path = 'raw';

fileList = dir(path);
fileList = fileList(~[fileList.isdir]); %remove directories
[junk, sortorder] = sort([fileList.datenum]);
fileList = fileList(sortorder); %list is now in ascending date order
numfiles = numel(fileList);
%In = cell(numfiles,1);
i=1;

for ii = 3:numfiles
   fp = sprintf('%s/%s',path,fileList(ii).name);
   fid = fopen(fp);
   fprintf('opening %s\n',fp);
   
   while ~feof(fid)
       s = fgetl(fid);
       if (findstr(s, 'depthNum') )
           %fprintf('%s\n',s);
           C = strsplit(s,', ');
           if( size(C,2)==5)
            D = char(C(5));
            A = sscanf(D,'depthNum = %d %f %f %f');
            %disp(A(4));
            battV(i)=A(4);
            i=i+1;
           end
       end
   end
   
   
   fclose(fid);
end

plot(battV);
grid on;
title('CPF batt discharge curve 15MAR2016, at sea');
ylabel('Volts');