%ititeratively process all files, merge and generate a file for MGL data
    clear all
    close all
% pathkeeping
    mdir = cd;
    cd ..\mat_files;
    mat_dir = cd;
    cd ..\raw_data
    dat_dir = cd;
    
% get directory  
    rfiles = dir('*HOT321*log');
    cd(mdir)
    
% create mat files    
    for i=1:length(rfiles)
        fpath = [dat_dir '\' rfiles(i).name];
        proclog2mat(fpath,rfiles(i).name,mat_dir);
    end
    
 % merge files
    [all_min_data, all_min_time] = merge_minfiles;
    save([mat_dir '\MINAVG_HOT321.mat'],'all_min_time','all_min_data');
 
% invert all - check this function for each cruise
    invert_all(all_min_time,all_min_data)
    
% plot output
    figure
    plot(sdate,nLsum);ylabel('Total Particle Concetration (1.25-100 micron, #/L'); axis tight; datetick('x','mm-dd','keeplimits')

    figure
    loglog(dias,psdn); xlim([2 100]);
    ylim([10^-2 10^9]); ylabel('#/L/um'); xlabel('dias')   
      
    figure
    subplot(3,1,1)
        plot(sdate,Cmd_sm,'g-'); axis tight; datetick('x','mm-dd','keeplimits');
        ylabel('{\Sigma}1.25-2.0 {\mu}m C, {\mu}mol L^-^1'); 
   
    subplot(3,1,2)
        plot(sdate,Cmd_med,'k-');
        axis tight; datetick('x','mm-dd','keeplimits');
        ylabel('{\Sigma}2.0-20 {\mu}m C, {\mu}mol L^-^1'); 
   
    subplot(3,1,3)
        plot(sdate,Cmd_lg,'r-'); 
        axis tight; datetick('x','mm-dd','keeplimits');
        ylabel('{\Sigma}20-100 {\mu}m C, {\mu}mol L^-^1'); 
    
  
  