clear all
close('all')

%dat-data(p, T, S, O, F_ref, F_sig, LSS_ref, LSS_Sig, theta, sigma,
%   O2sat, O2, chl, B_LSS

load apex_data
% compile dat files into one
for i=1:N %for files 1 through end - N from gen_msg_data
    file_i=int2str(i); %change i to string and store as file_i
    n=length(file_i); %gets length of string file_i
        if n==1 %if length is 1 (i is 1,2,3....9)
            name2=['dat00',file_i]; %concatenate dat00 and file_i (dat001, dat002, dat003...dat009) and store in array name2
        elseif n==2 %if length is 2 (i is 10, 11, 12...99)
             name2=['dat0',file_i]; %concatenate dat0 and file_i (dat010, dat011, dat012...dat099) and store in array name2
        else %if length is 2 (i is 100, 101, 102...999)
             name2=['dat',file_i]; %concatenate dat and file_i (dat100, dat101, dat102...dat999) and store in array name2
        end
    B=eval(name2); %takes strings in dat001 and changes to numbers, then assigns to array B
    [mm nn]=size(B); %returns number of rows and columns in B (dat001)
    if i==1 %if this is the first time through
        dat=[B]; %make array dat with B and a 15th column of zeros (for as many rows as there are in B)
    else %if this is not the first time through
        AA=[B]; %make array AA with B and a 15th column of ?? time from start?
        dat=[dat;AA]; %append array AA to dat and make array AA - should have 6 data fields plus empty columns
    end
end
[mm nn]=size(dat); %get size of data
data=zeros(mm,2); %initialize data
a=dat(:,1); %get column 1 - pressure - of dat
b=dat(:,6); %get column 6 - F_sig - of dat
data(:,1)=a; %add pressure to data
data(:,2)=b; %add chl to data
%
I=find(a>950);
MeanChl=min(b(I))

