% wall_plots.m; Ledwell; 9/10/05
% Plots profiles, 6 to a page

load cez

figure(1); clf; fig_portrait
for i=1:6
    subplot(3,2,i)
    C=Cmat(:,i);
    E=Emat(:,i);
    z=zmat(:,i);
    j=find(~isnan(C));
    plot(C(j),z(j),'--')
    xerrbar(C(j),z(j),E(j))
    axis([0 100 -60 60])
    text(50,45,['Tow ',int2str(i)])
    if i==3
        ylabel('z  (m)')
    end
    if i==5
        xlabel('C  (fM)')
    end
end

figure(2); clf; fig_portrait
for k=1:5
    subplot(3,2,k)
    i=k+6;
    C=Cmat(:,i);
    E=Emat(:,i);
    z=zmat(:,i);
    j=find(~isnan(C));
    plot(C(j),z(j),'--')
    xerrbar(C(j),z(j),E(j))
    axis([0 100 -60 60])
    text(50,45,['Tow ',int2str(i)])
    if k==3
        ylabel('z  (m)')
    end
    if k==5
        xlabel('C  (fM)')
    end
end

zr=[-50:1:50]';
m=length(zr);
n=11;

load cez
zmat(:,9:n)=zmat(:,9:n)+10;

Cint=NaN*ones(m,n);
Eint=cint;

for i=1:n
    k=find(~isnan(Cmat(:,i)));
    Cint(:,i)=interp1(zmat(k,i),Cmat(k,i),zr);
    Eint(:,i)=interp1(zmat(k,i),Emat(k,i),zr);
end
    
[J,N]=sum_nan(Cint');

[Cbar,Ebar,nbar]=mean_r(Cint,Eint,J);

subplot(3,2,6)
plot(Cbar,zr)
ke=5:10:95;
axis([0 25 -60 60])
xerrbar(Cbar(ke),zr(ke),Ebar(ke));
text(6,45,['Mean Profile'])
xlabel('C  (fM)')
   