close all
clear all

%ResultsPath = 'Copy-Results_Mar-19-2015_10-23-19\';
ResultsPath = 'Copy-Results_Mar-25-2015_10-32-39\';



ChargeFiles = dir([ResultsPath 'ChargeData_Cycle*.txt']);
DischargeFiles = dir([ResultsPath 'DischargeData_Cycle*.txt']);

for i = 1:min(length(ChargeFiles),length(DischargeFiles))
  i
  [date time VmonLow ImonLow VmonHigh ImonHigh ImonHighMean] = textread([ResultsPath ChargeFiles(i).name],'%s %s %f %f %f %f %f');   

  datenumber = datenum(strcat(date,time),'dd-mmm-yyyyHH:MM:SS');
  ElapsedTime = datenumber(end)-datenumber(1);
%   clear datenumber;
%   for j = 1:length(date)
%     datenumber(j) = datenum(sprintf('%s %s',date{j},time{j}));
%   end
  
  figure('Position',[ 1000         589        1366         909],'PaperPositionMode','manual','PaperOrientation','landscape','PaperType','usletter','PaperPosition',[0 0 11 8.5]);

  subplot(2,1,1)
  plot(datenumber,ImonHigh,datenumber,ImonLow,datenumber,ImonHighMean)
  hold on
  plot(datenumber,ImonHigh,'x')
  xlabel('date/time');
  datetick('x');
  ylabel('Charge Current (A)');
  legend('High Rate','Low Rate','Mean HighRate');
  title([ChargeFiles(i).name '   Elapsed Time = ' num2str(ElapsedTime*24) ' Hrs']);
  
  [date time VmonLow ImonLow VmonHigh ImonHigh] = textread([ResultsPath DischargeFiles(i).name],'%s %s %f %f %f %f ');   

  datenumber = datenum(strcat(date,time),'dd-mmm-yyyyHH:MM:SS');
  ElapsedTime = datenumber(end)-datenumber(1);

  subplot(2,1,2)
  plot(datenumber,VmonHigh,datenumber,VmonLow)
  xlabel('date/time');
  datetick('x');
  ylabel('Discharge Voltage (V)');
  legend('High Rate','Low Rate');
  title([DischargeFiles(i).name '   Elapsed Time = ' num2str(ElapsedTime*24) ' Hrs']);
  
  print('-dpdf',[ResultsPath(6:end-1) '-Cycle_' num2str(i)]);
  
end