% Determination of formation K for
%   the iodine-iodide-trijodide equilibrium.
% The files including the measured spectra are supposed to be saved
%   in form of WinAspect v1.5 (Jena Analytik Specord instruments).
pkg load optim;
clear all;
debugmode=false;
% The value of variable 'lang' can be 1 or 2 standing Hungarian or English
%   language, respectively.
if (debugmode)
  lang=2;
else
  lang=listdlg("ListSize",[200 70],"Name","Nyelv/Language", ...
    "SelectionMode","Single", ...
    "PromptString","Va\'lasszon nyelvet!/Choose language!", ...
    "ListString",{"Magyar/Hungarian","Angol/English"});
endif
% The value of variable 'basename' is the common part of file names.
if (debugmode)
  basename="PATD";
else
  if (lang == 2)
    bncaption='Case sensitive name';
    bnask='Type the basename of the measurement (max. 5 characters):';
  else
    bncaption="Ne\'v (\"a\"=\"A\" nem igaz!)";
    bnask="Adja meg a me\'re\'s alapneve\'t (max. 5 karakter):";
  endif
  basename=inputdlg(bnask,bncaption){1};
  clear bncaption bnask;
endif
sxtitle1='\lambda (nm)';
if (lang == 2)
  actdate=datestr(datenum(date),"mm/dd/yyyy");
  wtitle="Wavelengths (nm)";
  for i=1:7
    wnumbers{i}=["Wavelength " dec2base(i,10) ":"];
  endfor 
  ertit1=["At least one wavelength does not\n" ...
    "fit to the measured absorbancies"];
  ercaption="Attention!";
  compname="Computations";
  compcapt="Choose a task!";
  cfit="Fit at ";
  cnm=" nm.";
  cnmall="all wavelengths.";
  tablesum="Results of computations.";
  lastf="Distribution diagram.";
  eofcalc="End of computations.";
  stitle2=[basename ' series (' actdate '): '];
  meas="Measured data";
  fitted="Fitted curve";
  fitted1="Fitted curves";
  meas2="Transformed measured data";
  fitted2="Theoretical curve";
  msg1="By clicking the  OK button,";
  msg2="the figure is saved.";
  msgtitle="Save";
  cvg01="There has been an error indicated by cvg=";
  cvg02=" value!";
  cvg03="There is no saving.";
  cvgtitle="Error!";
  title9="All wavelengths, ";
  title10="Distribution diagram, ";
  stitle1=['Measured spectra (with ' basename ' as series name, ' actdate ')'];
  sytitle1='Absorbance';
  legendtitle='T(iodide)/M';
  c1title='T(iodine)/M';
  fitpar="Fitting parameter: ";
  restitle="Results";
  resmsg="The results have been written into the ";
  resmsg2=" file.";
else
  actdate=datestr(datenum(date),"yyyy.mm.dd.");
  wtitle="Hulla\'mhosszak (nm)";
  for i=1:7
    wnumbers{i}=[dec2base(i,10) ". hulla\'mhossz:"];
  endfor
  ertit1=["Legala\'bb egy hulla\'mhossz nem \n" ...
    "felel meg a me\'rt abszorbancia\'knak"];
  ercaption="Figyelem!"; 
  compname="Sza\'mola\'sok";
  compcapt="Va\'lasszon feladatot!";
  cfit="Illeszte\'s ";
  cnm=" nm-en.";
  cnmall="minden hulla\'mhosszon.";
  tablesum="Eredme\'nyek ta\'bla\'zata.";
  lastf="Eloszla\'si diagramm.";
  eofcalc="Sza\'mola\'sok ve\'ge.";
  stitle2=[basename ' sorozat (' actdate '): '];
  meas="Me\'rt adatok";
  fitted="Illesztett go\"rbe";
  fitted1="Illesztett go\"rbe\'k";
  meas2="Transzforma\'lt me\'re\'si adatok";
  fitted2="Elme\'leti go\"rbe";
  msg1="Az OK gomra kattintva";
  msg2="az a\'bra mentve lesz.";
  msgtitle="Mente\'s";
  cvg01="Hiba\'s illeszte\'s cvg=";
  cvg02=" e\'rte\'kkel!";
  cvg03="Nincs mente\'s.";
  cvgtitle="Hiba!";
  title9="O\"sszes hulla\'mhossz, ";
  title10="Eloszla\'si diagramm, ";
  stitle1=["Me\'rt spektrumok (" basename ' sorozat, ' actdate ')'];
  sytitle1='Abszorbancia';
  legendtitle='T(jodid)/M';
  c1title="T(jo\'d)/M";
  fitpar="A\'­tlagos elte\'re\'s: ";
  restitle="Eredme\'nyek";
  resmsg="Az eredme\'nyek a(z) ";
  resmsg2=" fa\'jlban vannak.";
endif
% The variable 'Tfiles' is a matrix consisting of three columns. In each row,
%   the first (real) value is the total iodine concentration,
%   the second (real) value is the total iodide concentration and
%   the third (integer) value is the number in the name of the corresponding
%   file.
% The first row must include data for the reference spectra, i.e.,
%   both concentrations must be zero.
% The values are separated by space and each row but the last one
%   is ended by semicolon. For example:
% Tfiles=[
% 0.0        0.0       0;
% 0.0007969	0.0000000 2;
% 0.0007971	0.0000638 3;
% 0.0007975	0.0001596 4;
% 0.0007981	0.0003192 5;
% 0.0007990	0.0005586 6;
% 0.0008003	0.0009097 7;
% 0.0008016	0.0012768 8;
% 0.0008037	0.0018354 9;
% 0.0008067	0.0026334 10;
% 0.0008114	0.0039102 11;
% 0.0008206	0.0063840 12;
% 0.0008478	0.0137256 13;
% 0.0008709	0.0199500 14
% ];
% If the data is in a text file, the syntax is the same but the semicolon
% should not be placed.
Tfiles=load([basename ".cnc"]);
% In variable 'w', the wavelength values are collected.
% In variable 'mabs', the measured absorbances are collected. Each column
%   contains one spectra.
for ic=1:size(Tfiles)(1)
  f=fopen(["./" basename dec2base(Tfiles(ic,3),10,3) ".DAT"],"r");
  f_as_i=fread(f,"uint8")';
  f_as_s=char(f_as_i);
  fclose(f);
  i=8+index(f_as_s,"NPOINTS");
  j=i;
  while (f_as_s(j) > " ")
    j=j+1;
  endwhile
  npoints=str2double(f_as_s(i:j-1));
  i=8+index(f_as_s,"XDATA");
  j=8+index(f_as_s,"YDATA");
  for k=1:npoints
    if (ic < 1.5)
      w(k,1)=hex2num([dec2hex(f_as_i(i+3),2),dec2hex(f_as_i(i+2),2), ...
        dec2hex(f_as_i(i+1),2),dec2hex(f_as_i(i),2)],"single");
    endif
    mabs(k,ic)=hex2num([dec2hex(f_as_i(j+3),2),dec2hex(f_as_i(j+2),2), ...
      dec2hex(f_as_i(j+1),2),dec2hex(f_as_i(j),2)],"single");
    i=i+4;
    j=j+4;
  endfor
  if (ic > 1.5)
    mabs(:,ic)=mabs(:,ic)-mabs(:,1);
  endif
endfor
w=int32(w);
clear f f_as_i f_as_s npoints ic;
Tfiles(1,:)=[];
mabs(:,1)=[];
mabs(size(mabs)(1)+1,:)=Tfiles(:,2)';
mabs=sortrows(mabs',size(mabs)(1))'(1:end-1,:);
Tfiles=sortrows(Tfiles,2);
clf;
figure(1,"position",[20 100 413 585], ...
  "papertype","a4","paperposition",[0.25 0.25 7.769 11.189]);
subplot(11,1,1:7)
hold on;
grid on;
axis([w(1) w(size(w)(1)) 0.0 2.0]);
title(stitle1,"interpreter","tex");
xlabel(sxtitle1,"interpreter","tex");
ylabel(sytitle1,"interpreter","tex");
plot([w(1)],[0.0],"marker","none","linestyle","none","displayname",legendtitle);
for i=1:size(Tfiles)(1)
  plot(w,mabs(:,i),"linewidth",2,"displayname",num2str(Tfiles(i,2),"%9.7f"));
endfor
legend("show");
if (debugmode)
  wls=int32(sort([452 460 468 476 488 510 532]));
else
  for i=1:7
    wlss{i}="";
  endfor
  do
    wlss=inputdlg(wnumbers,wtitle,[1,30;1,30;1,30;1,30;1,30;1,30;1,30;], ...
      sort(wlss));
    wls=int32(sort(str2double(wlss)))';
    j=1;
    for k=1:size(w)(1)
      if (abs(w(k)-wls(j)) < 0.1)
        wlss{j}=dec2base(w(k),10);
        j=j+1;
        if (j > 7.1)
          break
        endif
      endif
    endfor
    if (j < 7.1)
      errordlg(ertit1,ercaption);
    endif
  until (j > 7.1)
  clear wnumbers wtitle wlss ertit1 ercaption
endif
i=1;
clear redmabs
while (i<7.5)
  j=1;
  do
    k=abs(w(j)-wls(i));
    j=j+1;
  until (k<1) | (j>size(w)(1))
  if (j>size(w)(1))
    i=11;
  else
    redmabs(:,i)=mabs(j,:)';
    i=i+1;
  endif
endwhile
redmabs=double(redmabs);
plot([wls;wls],[0.0;2.0],"color",[0.7 0.7 0.7],"linestyle",":");
subplot(11,1,8:11)
axis off;
text(0,0.85,c1title,"fontsize",9);
text(1/7,0.85,legendtitle,"fontsize",9);
for j=1:7
  text(j/9.6+0.2,0.85,["A(" num2str(wls(j),"%3.0f") ")"],"fontsize",9);
endfor
for i=1:size(redmabs)(1)
  for j=1:2
    text((j-1)/7,0.8-0.06*i,num2str(Tfiles(i,j),"%9.7f"),"fontsize",9);
  endfor
  for j=1:7
    text(j/9.6+0.2,0.8-0.06*i,num2str(redmabs(i,j),"%6.4f"),"fontsize",9);
  endfor
endfor
print(1,[basename "_curves.pdf"]);
close;
% Setting the initial parameter values
pars(1)=1/Tfiles(int32(size(Tfiles)(1)/2),2);
for i=1:7
  pars(2*i)=redmabs(1,i)/Tfiles(1,1);
  pars(2*i+1)=redmabs(size(redmabs)(1),i)/Tfiles(size(Tfiles)(1),1);
endfor

% Function that will be fit
function [Ac]=I3equilibrium(par,TIs)
  K=par(1);
  if (size(par)(1)*size(par)(2) > 5)
    EI2=par(2:2:end)';
    EI3=par(3:2:end)';
  else
    EI2=par(2);
    EI3=par(3);
  endif
  tmph=1/K.+TIs(:,1).+TIs(:,2);
  tmpg=tmph.^2-4.*TIs(:,1).*TIs(:,2);
  for i=1:size(tmpg)(1)
    if (tmpg(i,1) < 0.0)
      tmpg(i,1)=0.0;
    endif
  endfor
  Ac=TIs(:,1)*EI2+((tmph-sqrt(tmpg))/2)*(EI3.-EI2);  
endfunction
settings=optimset("objf_type","wls", "MaxIter",20, "TolFun",1.0E-4, ...
  "ret_covd", true, "ret_covp", true, "ret_corp", true);
clear complist
for i=1:7
  complist{i}=[cfit dec2base(wls(i),10) cnm];
endfor
complist{8}=[cfit cnmall];
complist{9}=tablesum;
complist{10}=lastf;
complist{11}=eofcalc;
nfit=zeros(8,1);
clear result;
result={};
do
  if (sum(nfit) > 7.1)
    [k,j]=listdlg("ListSize",[250 230],"Name",compname, ...
      "SelectionMode","Single","PromptString",compcapt,"ListString",complist);
  else
    [k,j]=listdlg("ListSize",[250 200],"Name",compname, ...
      "SelectionMode","Single","PromptString",compcapt,"ListString", ...
      [complist(1:8) complist(11)]);
  endif
  switch (k)
    case {1,2,3,4,5,6,7}
      par0=[pars(1);pars(2*k);pars(2*k+1)];
      [pact,Ac,cvg,outp]=nonlin_curvefit(@I3equilibrium,par0, ...
        Tfiles(:,1:2),redmabs(:,k),settings);
      if (cvg > 0)
        nfit(k)=1;
        info=curvefit_stat(@I3equilibrium,par0, ...
          Tfiles(:,1:2),redmabs(:,k),settings);
        result{k}.averresi=(sum((Ac.-redmabs(:,k)).^2) ...
          /(numel(redmabs(:,k))-numel(pact)))^0.5;
        clear diagcovp;
        for i=1:size(info.covp)
          diagcovp(i)=info.covp(i,i);
        endfor
        result{k}.pact=pact;
        result{k}.sepact=((diagcovp./info.covd(1,1)).^0.5.*result{k}.averresi)';
        clf;
        figure(1,"position",[20 100 413 585], ...
          "papertype","a4","paperposition",[0.25 0.25 7.769 11.189]);
        subplot(11,1,1:5)
        hold on;
        grid on;
        title(stitle2,"interpreter","tex");
        xlabel(legendtitle,"interpreter","tex");
        ylabel([sytitle1 " (" dec2base(wls(k),10) " nm)"],"interpreter","tex");
        plot(Tfiles(:,2),redmabs(:,k),"o","displayname",meas, ...
          "markersize",5.0,"color","black", ...
          "markeredgecolor","auto","markerfacecolor","auto");
        plot(Tfiles(:,2),Ac,"color","red","linewidth",2, ...
          "displayname",fitted);
        legend("location","east");
        legend("show");
        subplot(11,1,7:11)
        hold on;
        grid off;
        xlabel(["lg(" legendtitle ")"],"interpreter","tex");
        ylabel([sytitle1 " (" dec2base(wls(k),10) " nm)"],"interpreter","tex");
        plot(log10(Tfiles(2:end,2)),redmabs(2:end,k),"o", ...
          "markersize",5.0,"color","black", ...
          "markeredgecolor","auto","markerfacecolor","auto");
        plot(log10(Tfiles(2:end,2)),Ac(2:end),"color","red","linewidth",2);
        xia=get(gca(),"xlim");
        yia=get(gca(),"ylim");
        if (k < 4)
          yas(1)=0.03*yia(1).+0.97*yia(2);
          yas(2)=0.10*yia(1).+0.90*yia(2);
          yas(3)=0.17*yia(1).+0.83*yia(2);
          yas(4)=0.24*yia(1).+0.76*yia(2);
        else
          yas(1)=0.76*yia(1).+0.24*yia(2);
          yas(2)=0.83*yia(1).+0.17*yia(2);
          yas(3)=0.90*yia(1).+0.10*yia(2);
          yas(4)=0.97*yia(1).+0.03*yia(2);
        endif
        text(0.99*xia(1).+0.01*xia(2),yas(1), ...
          [fitpar num2str(result{k}.averresi,"%6.4f") " AU"],"fontsize",9);
        text(0.99*xia(1).+0.01*xia(2),yas(2), ...
          ['K=(' num2str(result{k}.pact(1),"%6.3e") '+-' ...
          num2str(result{k}.sepact(1),"%4.1e") ") 1/M"],"fontsize",9);
        text(0.99*xia(1).+0.01*xia(2),yas(3), ...
          ['E(I2)=(' num2str(result{k}.pact(2),"%6.3e") '+-' ...
          num2str(result{k}.sepact(2),"%4.1e") ") 1/M/cm"],"fontsize",9);
        text(0.99*xia(1).+0.01*xia(2),yas(4), ...
          ['E(I3-)=(' num2str(result{k}.pact(3),"%6.3e") '+-' ...
          num2str(result{k}.sepact(3),"%4.1e") ") 1/M/cm"],"fontsize",9);
        legend("off");
        msgbox({msg1 msg2},msgtitle);
        saveas(1,[basename "_" dec2base(wls(k),10) "nm.pdf"]);
        close;
      else
        result{k}.averresi=NA;
        result{k}.pact="no";
        result{k}.sepact="no";
        msgbox({[cvg01 num2str(cvg,"%2.0f") cvg02] cvg03},cvgtitle);
      endif
    case 8
      par0=pars';
      [pact,Ac,cvg,outp]=nonlin_curvefit(@I3equilibrium,par0, ...
        Tfiles(:,1:2),redmabs,settings);
      if (cvg > 0)
        nfit(8)=1;
        info=curvefit_stat(@I3equilibrium,par0, ...
          Tfiles(:,1:2),redmabs,settings);
        result{k}.averresi=(sum(sum((Ac.-redmabs).^2)) ...
          /(numel(redmabs)-numel(pact)))^0.5;
        clear diagcovp;
        for i=1:size(info.covp)
          diagcovp(i)=info.covp(i,i);
        endfor
        result{k}.pact=pact;
        result{k}.sepact=((diagcovp./info.covd(1,1)).^0.5.*result{k}.averresi)';
        clf;
        figure(1,"position",[20 100 413 585], ...
          "papertype","a4","paperposition",[0.25 0.25 7.769 11.189]);
        subplot(11,1,1:5)
        hold on;
        grid on;
        title([title9 stitle2],"interpreter","tex");
        xlabel(legendtitle,"interpreter","tex");
        ylabel(sytitle1,"interpreter","tex");
        plot(Tfiles(:,2),redmabs(:,1),"o","displayname",meas, ...
          "markersize",5.0,"color","black", ...
          "markeredgecolor","auto","markerfacecolor","auto");
        plot(Tfiles(:,2),Ac(:,1),"color","red","linewidth",2, ...
          "displayname",fitted);
        plot(Tfiles(:,2),redmabs(:,2:end),"o","markersize",5.0, ...
          "color","black","markeredgecolor","auto","markerfacecolor","auto");
        plot(Tfiles(:,2),Ac(:,2:end),"color","red","linewidth",2);
        legend("off");
        subplot(11,1,7:11)
        hold on;
        grid on;
        xlabel(["lg(" legendtitle ")"],"interpreter","tex");
        ylabel(sytitle1,"interpreter","tex");
        plot(log10(Tfiles(2:end,2)),redmabs(2:end,1),"o","markersize",5.0, ...
          "color","black","markeredgecolor","auto","markerfacecolor","auto");
        plot(log10(Tfiles(2:end,2)),Ac(2:end,1),"-","color","red", ...
          "linewidth",2);
        plot(log10(Tfiles(2:end,2)),redmabs(2:end,2:end),"o", ...
          "markersize",5.0,"color","black", ...
          "markeredgecolor","auto","markerfacecolor","auto");
        plot(log10(Tfiles(2:end,2)),Ac(2:end,2:end),"-","color","red", ...
          "linewidth",2);
        legend({meas fitted1},"location","NorthWest");
        msgbox({msg1 msg2},msgtitle);
        print(1,[basename "_all.pdf"]);
        close;
      else
        result{k}.averresi=NA;
        result{k}.pact="no";
        result{k}.sepact="no";
        msgbox({[cvg01 num2str(cvg,"%2.0f") cvg02] cvg03},cvgtitle);
      endif
      case 9
        fidres=fopen([basename "_results.txt"],"w");
        fprintf(fidres,[stitle2 "\r\n"]);
        fprintf(fidres,"\r\n");
        if (lang == 1)
          fprintf(fidres,"Hullámhosszankénti illesztések eredményei:\r\n");
          fprintf(fidres,"\r\n");
          fprintf(fidres,["Hullám-                                        " ...
            "                        ­­­­Átlagos\r\n"]);
          fprintf(fidres,["hossz   Kc (1/M)             E(I2) (1/M/cm)" ...
            "       E(I3-) (1/M/cm)      eltérés\r\n"]);
        else
          fprintf(fidres,"Result of fit used single wavelengths:\r\n");
          fprintf(fidres,"\r\n");
          fprintf(fidres,["Wave-                                      " ...
            "                            Fitting\r\n"]);
          fprintf(fidres,["length  Kc (1/M)             E(I2) (1/M/cm)" ...
            "       E(I3-) (1/M/cm)      parameter\r\n"]);
        endif
        for k=1:7
          if (isna(result{k}.averresi))
            if (lang == 1)
              fprintf(fidres,"%3u nm  Nincs eredmény!\r\n",wls(k));
            else
              fprintf(fidres,"%3u nm  There is not any result!\r\n",wls(k));
            endif
          else
            fprintf(fidres,["%3u nm  %10.3e+-%8.1E %10.3e+-%8.1E " ...
              "%10.3e+-%8.1E %6.4f\r\n"],wls(k), ...
              result{k}.pact(1),result{k}.sepact(1), ...
              result{k}.pact(2),result{k}.sepact(2), ...
              result{k}.pact(3),result{k}.sepact(3), ...
              result{k}.averresi);
          endif
        endfor
        fprintf(fidres,"\r\n");
        if (lang == 1)
          fprintf(fidres,"Együttes illesztés eredménye:\r\n");
          fprintf(fidres,"\r\n");
          fprintf(fidres,["Hullám-                                        " ...
            "                        ­­­­Átlagos\r\n"]);
          fprintf(fidres,["hossz   Kc (1/M)             E(I2) (1/M/cm)" ...
            "       E(I3-) (1/M/cm)      eltérés\r\n"]);
        else
          fprintf(fidres,["Result of fit used all wavelengths " ...
            "simultaneously:\r\n"]);
          fprintf(fidres,"\r\n");
          fprintf(fidres,["Wave-                                      " ...
            "                            Fitting\r\n"]);
          fprintf(fidres,["length  Kc (1/M)             E(I2) (1/M/cm)" ...
            "       E(I3-) (1/M/cm)      parameter\r\n"]);
        endif
        fprintf(fidres,["        %10.3e+-%8.1E                      " ...
          "                     %6.4f\r\n"], ...
          result{8}.pact(1),result{8}.sepact(1), ...
          result{8}.averresi);
        for k=1:7
          fprintf(fidres,["%3u nm                       %10.3e+-%8.1E " ...
            "%10.3e+-%8.1E\r\n"],wls(k), ...
            result{8}.pact(2*k),result{8}.sepact(2*k), ...
            result{8}.pact(2*k+1),result{8}.sepact(2*k+1));
        endfor
        fclose(fidres);
        msgbox([resmsg basename "_results.txt" resmsg2],restitle);
      case 10
        cI3=(redmabs-Tfiles(:,1)*result{8}.pact(2:2:end)')./ ...
          (result{8}.pact(3:2:end).-result{8}.pact(2:2:end))';
        x=result{8}.pact(1).*(Tfiles(:,2)-cI3);
        logx=real(log10(x));
        y=cI3./Tfiles(:,1);
        clf;
        figure(1,"position",[20 100 413 585], ...
          "papertype","a4","paperposition",[0.25 0.25 7.769 11.189]);
        subplot(11,1,1:5)
        hold on;
        grid on;
        title([title10 stitle2],"interpreter","tex");
        xlabel("lg(x)","interpreter","tex");
        ylabel("y","interpreter","tex");
        plot(logx,y,"o","displayname",meas, ...
          "markersize",5.0,"color","black", ...
          "markeredgecolor","auto","markerfacecolor","auto");
        xval=min(min(logx)):0.01:max(max(logx));
        yval=10.^xval;
        yval=yval./(1.0.+yval);
        plot(xval,yval,"color","red","linewidth",2, ...
          "displayname",fitted);
        legend("off");
        subplot(11,1,7:11)
        hold on;
        grid on;
        axis([-3 3 -0.1 1.1]);
        axis("autox");
        xlabel("lg(x)","interpreter","tex");
        ylabel("y","interpreter","tex");
        plot(reshape(logx,prod(size(logx)),1),reshape(y,prod(size(y)),1), ...
          "o","displayname",meas,"markersize",5.0,"color","black", ...
          "markeredgecolor","auto","markerfacecolor","auto");
        plot(xval,yval,"color","red","linewidth",2, ...
          "displayname",fitted);
        legend({meas2 fitted2},"location","NorthWest");
        legend("show");
        msgbox({msg1 msg2},msgtitle);
        print(1,[basename "_distribution.pdf"]);
        close;
      case 11
        clear c1title cfit cnall cnm cnmall compcapt complist compname actdate;
        clear cqtitle cvg cvg01 cvg02 cvg03 cvgtitle debugmode diagcovp wtitle;
        clear eofcalc ercaption ertit1 fidres fitpar fitted fitted1 fitted2 xia;
        clear i info j lang lastf legendtitle meas meas2 msg1 msg2 msgtitle yia;
        clear nfit outp pact par0 pars resmsg resmsg2 restitle settings xval;
        clear stitle1 stitle2 sxtitle1 sytitle1 tablesum title10 title9 yval;
  endswitch
until ((k > 10.1) || (j == 0))
clear k;
% Current version: 0.03.11/06/2017
%   Total concentrations are also sorted before any calculation.
%   Some errors in the description have been corrected.
% Version: 0.02.11/03/2017
%   Date is also given in the output files.
%   The decision way about the possible menu items has been modified.
%   The figures belonging to the individual curves and to the distribution 
%     diagram have slighty been modified.
%   Debugmode is introduced for debugging.
%   The size parameters for the figures have been modified.
%   The print command has been replaced by saveas.
% Version 0.01.10/25/2017
%   Initial version has been published.
