

clear all
close all
%make a large matrix with all CNR data
for i=1:91
    path='/Volumes/Data2/TaraEuropa/Partner_data/CNR-P/Absorption spectra/';
    filename=[path,'ST_ag',num2str(i),'.mat'];
    load(filename)
    wl_ag=wl;
    B(i,:)=ag_ave;
    C(i,:)=ag_std;
end
    filename=['/Volumes/Data2/TaraEuropa/Partner_data/CNR-P/Absorption spectra/CNR_DOC_TOC.mat'];
    load (filename)
    I=1:20, 63:91;
    DOC=A.DOC_MeanuM;
for i=1:length(wl)
    A=corrcoef(B(I,i),DOC(I));
    R(i)=A(1,2);
    %p(i,:)= polyfit(DOC(I),B(I,i),1);
end
plot(wl,R,'b','LineWidth',2)
ylabel('correlation coefficient between a(\lambda_i) and DOC')
xlabel('\lambda')
hold on
    filename=['/Volumes/Data2/TaraEuropa/Partner_data/CNR-P/Absorption spectra/CNR_DOC_TOC.mat'];
    load (filename)
    I=21:62;
    DOC=A.DOC_MeanuM;
for i=1:length(wl)
    A=corrcoef(B(I,i),DOC(I));
    R(i)=A(1,2);
    %p(i,:)= polyfit(DOC(I),B(I,i),1);
end

plot(wl,R,'g','LineWidth',2)
    filename=['/Volumes/Data2/TaraEuropa/Partner_data/CNR-P/Absorption spectra/CNR_DOC_TOC.mat'];
    load (filename)

    I=1:91;
    DOC=A.DOC_MeanuM;
for i=1:length(wl)
    A=corrcoef(B(I,i),DOC(I));
    R(i)=A(1,2);
    %p(i,:)= polyfit(DOC(I),B(I,i),1);
end

plot(wl,R,'k','LineWidth',2)
ylabel('correlation coefficient between a(\lambda_i) and DOC')
xlabel('\lambda')
legend('Outside Baltic','in Baltic','all stations')



%semilogy(wl,p(:,1))
% hold on;
% semilogy(wl,0.22*exp(-0.014*(wl-500)),'k')
% axis([500 600 0 4])
% hold off

