g=zeros(m,5);
clear inex ub taubm taucm tauim;
g(:,1)=u10n_f';
g(:,2)=taub_f'./rhoar_f';
g(:,3)=tauc_f'./rhoar_f';
g(:,4)=tauij_f'./rhoar_f';
g(:,5)=gust_f';
h=sortrows(g,1);

ff=0;
j=1;
for i=1:m
   if floor(h(i,1))>ff
      inex(j)=i;
      j=j+1;
      ff=ff+1;
    	if j==12;ff=ff+2;end;
   end;
end;
kk=1;
for i=1:j-1
   ll=inex(i)-1;
   ub(i)=median(h(kk:ll,1));
   taubm(i)=median(h(kk:ll,2));
   taucm(i)=median(h(kk:ll,3));
   tauim(i)=median(h(kk:ll,4));
   gustm(i)=median(h(kk:ll,5));
   kk=inex(i);
end;
	
figure;plot(ub,taucm./taubm,'x',ub,tauim./taubm./sqrt(gustm),'o');axis([0 14 .6 1.5]);xlabel('Wind Speed (m/s)');ylabel('Stress Ratio to Bulk');
usc=sqrt(abs(taucm.*gustm));
usb=sqrt(abs(taubm).*gustm);
usi=sqrt(abs(tauim));
%sp=ub.*gustm
sp=ub;
z0=10./exp(.4*sp./usc);
z0b=10./exp(.4*sp./usb);
z0i=10./exp(.4*sp./usi);

charn=(z0-.11*1.55e-5./usc)*9.83./usc.^2;
charnb=(z0b-.11*1.55e-5./usb)*9.83./usb.^2;
charni=(z0i-.11*1.55e-5./usi)*9.83./usi.^2;


figure;plot(ub,charnb,ub,charn,'x',ub,charni,'o');axis([0 14 0 0.025]);xlabel('Wind Speed (m/s)');ylabel('Charnock Constant');
