% Magdalena Gorylova mgg0.m
% reads info from MicrOptics e.g.
% 44140,3579772455;25,0;
% decodes time and temperature regardles of delimiters
% uses mami0.m
% Mysa 09. 11. 2020
function [xyzz, strstr, endstr]=mgg0(varargin)
if nargin>0 ifilen=varargin{1}; else ifilen='./ddata/T_051120.txt'; end
if nargin>1 plotf=varargin{2}; else plotf=1; end
%xyzz=load('../data/T_051120.txt');
kk=0;
fid=fopen(ifilen);
while ~feof(fid)
  kk=kk+1;
  tline=deblank(fgetl(fid));
[ctimv, tss, ctemp]=mami0(tline);
txyz(kk,:)=[ctimv tss ctemp];
if kk==1 strstr=datestr(ctimv); end
%txyz(kk,:)=[ctim(:)' tes];
end
xyzz=txyz(:,7:8);
xyzz(:,1)=xyzz(:,1)-xyzz(1,1);
endstr=datestr(ctimv);
if plotf==1
  plot(xyzz(:,1),xyzz(:,2));
  xlabel('Time [s]');
  ylabel('Temperature [C]');
  legend('Plate\_T0');
  title([strstr,' - ',endstr]);
end
