disp('id.m')

if ddd<100,
   if ddd<10,
      ddd=['00',num2str(ddd)];
   else
      ddd=['0',num2str(ddd)];
   end
else
   ddd=num2str(ddd);
end;

if hhh<10,
   hhh=['0',num2str(hhh)];
else
   hhh=num2str(hhh);
end

%             2   3   4      5      6      7     8    9    10    11 12 13 14 15
%xship_6=[Ubar_6 Us Tsea_6 Tbar_6 Qsea_6 Qbar_6 Rs_6 Rl_6 rain_6 zi  P zu zt zq];
%         39   40  41 42 43  44  45 46 47  48  49   50    51 52 53      54 55 56  57    58      59   
%yship_6=[hsb hlb tau zo zot zoq L usr tsr qsr dter dqer tkt RF hl_webb Cd Ch Ce Cdn_10 Chn_10 Cen_10];

%                       1          2-15      16         17          18          19         20        21         22        23       24   25   26     27       28       29    30        31          32     33   34   35       36      37        38    39:59
%da_dddhhh =  ddd+hhh/24+00/24/60 xship_1 mean_wind_1 min_wind_1 max_wind_1 std_wind_1 mean_dir_1 min_dir_1 max_dir_1 std_dir_1 Ustr_1 Un_1 Ue_1 Twindir_1 Reldir_1 alpha_1 beta_1 Tseasnake_1 Tbarv_1 RHv_1 RH_1 Qbarv_1 Qbar_1 Qseasnake_1 rho_1 yship_1 ysnake_1 std_Rl_1 std_Rs_1 mean_head_1 std_head_1 min_head_1 max_head_1 mean_sog_1 std_sog_1 min_sog_1 max_sog_1 mean_cog_1 std_cog_1 min_cog_1 max_cog_1 mean_gpscog_1 std_gpscog_1 min_gpscog_1 max_gpscog_1 mean_gpsspeed_1 min_gpsspeed_1 max_gpsspeed_1 mean_gyro_1 std_gyro_1 min_gyro_1 max_gyro_1 wu_1(1,2) wuj_1(1,2) wv_1(1,2) wvj_1(1,2) wt_1(1,2) wtd_1(1,2) wtj_1(1,2) wa_1(1,2) waj_1(1,2) wh_1(1,2) wc_1(1,2) wu_1(1,1) wv_1(1,1) wu_1(2,2) wuj_1(1,1) wvj_1(1,1) wuj_1(2,2) wt_1(2,2) wa_1(2,2) wh_1(2,2) wc_1(2,2) mean_CO2_1 med_CO2_1 std_CO2_1 mean_H2Oa_1 med_H2Oa_1 std_H2Oa_1 mean_H2Op_1 med_H2Op_1 std_H2Op_1 mean_H2Ow_1 med_H2Ow_1 std_H2Ow_1 std_absorb_1 std_clear_1 med_clear_1 med_absorb_1 ...
%   Sp1_1 Sp2_1 Sp3_1 Ssin_1 Scos_1 Cu2_1_1 Cu2_1_2 Cw2_1_1 Cw2_1_2 Ct2_1_1 Ct2_1_2 Cq2_1_1 Cq2_1_2 Co2_1_1 Co2_1_2 Cc2_1_1 Cc2_1_2 usid_1_1 usid_1_2 tsid_1_1 tsid_1_2 qsid_1_1 qsid_1_2 osid_1_1 osid_1_2 csid_1_1 csid_1_2 Lid_1_1 Lid_1_2 Lon_1 Lat_1 Ubarj_1

%                       1         2:51  52:101 102:151 152:201 202:251 252:301 302:351 352:401 402:451 452:501 502:551 552:601 602:651 652:701 702:751 752:801 802:851 852:901 902:951
%sp_dddhhh =  ddd+hhh/24+00/24/60 Fson  Su_1   Sv_1    Sw_1    St_1    Sq_1    So_1    Sc_1    Suj_1   Svj_1   Swj_1   Cuw_1   Cvw_1   Ctw_1   Cqw_1   Cow_1   Ccw_1   Cuwj_1  Cvwj_1
sss=['load d:\temp\day',ddd,'\sp_',ddd,hhh,'.prn'];
eval(sss);clear sss
sss=['sp=sp_',ddd,hhh,';'];
eval(sss);clear sss
sss=['load d:\temp\day',ddd,'\da_',ddd,hhh,'.prn'];
eval(sss);clear sss
sss=['da=da_',ddd,hhh,';'];
eval(sss);clear sss

Qbar_1=da(1,7);Tbar_1=da(1,5);Ubar_1=da(1,2);Ustr_1=da(1,24);xship_1=da(1,2:15);yship_1=da(1,39:59);uu_1=da(1,120);vv_1=da(1,121);ww_1=da(1,122);
Qbar_2=da(2,7);Tbar_2=da(2,5);Ubar_2=da(2,2);Ustr_2=da(2,24);xship_2=da(2,2:15);yship_2=da(2,39:59);uu_2=da(2,120);vv_2=da(2,121);ww_2=da(2,122);
Qbar_3=da(3,7);Tbar_3=da(3,5);Ubar_3=da(3,2);Ustr_3=da(3,24);xship_3=da(3,2:15);yship_3=da(3,39:59);uu_3=da(3,120);vv_3=da(3,121);ww_3=da(3,122);
Qbar_4=da(4,7);Tbar_4=da(4,5);Ubar_4=da(4,2);Ustr_4=da(4,24);xship_4=da(4,2:15);yship_4=da(4,39:59);uu_4=da(4,120);vv_4=da(4,121);ww_4=da(4,122);
Qbar_5=da(5,7);Tbar_5=da(5,5);Ubar_5=da(5,2);Ustr_5=da(5,24);xship_5=da(5,2:15);yship_5=da(5,39:59);uu_5=da(5,120);vv_5=da(5,121);ww_5=da(5,122);
Qbar_6=da(6,7);Tbar_6=da(6,5);Ubar_6=da(6,2);Ustr_6=da(6,24);xship_6=da(6,2:15);yship_6=da(6,39:59);uu_6=da(6,120);vv_6=da(6,121);ww_6=da(6,122);

ck=length(sp);
if length(sp)==951,
   Fson=sp(1,2:51);
   Su_1=sp(1,52:101);Su_2=sp(2,52:101);Su_3=sp(3,52:101);Su_4=sp(4,52:101);Su_5=sp(5,52:101);Su_6=sp(6,52:101);
   Sv_1=sp(1,102:151);Sv_2=sp(2,102:151);Sv_3=sp(3,102:151);Sv_4=sp(4,102:151);Sv_5=sp(5,102:151);Sv_6=sp(6,102:151);
   Sw_1=sp(1,152:201);Sw_2=sp(2,152:201);Sw_3=sp(3,152:201);Sw_4=sp(4,152:201);Sw_5=sp(5,152:201);Sw_6=sp(6,152:201);
   St_1=sp(1,202:251);St_2=sp(2,202:251);St_3=sp(3,202:251);St_4=sp(4,202:251);St_5=sp(5,202:251);St_6=sp(6,202:251);
   Sq_1=sp(1,252:301);Sq_2=sp(2,252:301);Sq_3=sp(3,252:301);Sq_4=sp(4,252:301);Sq_5=sp(5,252:301);Sq_6=sp(6,252:301);
   So_1=sp(1,302:351);So_2=sp(2,302:351);So_3=sp(3,302:351);So_4=sp(4,302:351);So_5=sp(5,302:351);So_6=sp(6,302:351);
   Sc_1=sp(1,352:401);Sc_2=sp(2,352:401);Sc_3=sp(3,352:401);Sc_4=sp(4,352:401);Sc_5=sp(5,352:401);Sc_6=sp(6,352:401);
   Suj_1=sp(1,402:451);Suj_2=sp(2,402:451);Suj_3=sp(3,402:451);Suj_4=sp(4,402:451);Suj_5=sp(5,402:451);Suj_6=sp(6,402:451);
   Svj_1=sp(1,452:501);Svj_2=sp(2,452:501);Svj_3=sp(3,452:501);Svj_4=sp(4,452:501);Svj_5=sp(5,452:501);Svj_6=sp(6,452:501);
   Swj_1=sp(1,502:551);Swj_2=sp(2,502:551);Swj_3=sp(3,502:551);Swj_4=sp(4,502:551);Swj_5=sp(5,502:551);Swj_6=sp(6,502:551);
   Cuw_1=sp(1,552:601);Cuw_2=sp(2,552:601);Cuw_3=sp(3,552:601);Cuw_4=sp(4,552:601);Cuw_5=sp(5,552:601);Cuw_6=sp(6,552:601);
   Cvw_1=sp(1,602:651);Cvw_2=sp(2,602:651);Cvw_3=sp(3,602:651);Cvw_4=sp(4,602:651);Cvw_5=sp(5,602:651);Cvw_6=sp(6,602:651);
   Ctw_1=sp(1,652:701);Ctw_2=sp(2,652:701);Ctw_3=sp(3,652:701);Ctw_4=sp(4,652:701);Ctw_5=sp(5,652:701);Ctw_6=sp(6,652:701);
   Cqw_1=sp(1,702:751);Cqw_2=sp(2,702:751);Cqw_3=sp(3,702:751);Cqw_4=sp(4,702:751);Cqw_5=sp(5,702:751);Cqw_6=sp(6,702:751);
   Cow_1=sp(1,752:801);Cow_2=sp(2,752:801);Cow_3=sp(3,752:801);Cow_4=sp(4,752:801);Cow_5=sp(5,752:801);Cow_6=sp(6,752:801);
   Ccw_1=sp(1,802:851);Ccw_2=sp(2,802:851);Ccw_3=sp(3,802:851);Ccw_4=sp(4,802:851);Ccw_5=sp(5,802:851);Ccw_6=sp(6,802:851);
   Cuwj_1=sp(1,852:901);Cuwj_2=sp(2,852:901);Cuwj_3=sp(3,852:901);Cuwj_4=sp(4,852:901);Cuwj_5=sp(5,852:901);Cuwj_6=sp(6,852:901);
   Cvwj_1=sp(1,902:951);Cvwj_2=sp(2,902:951);Cvwj_3=sp(3,902:951);Cvwj_4=sp(4,902:951);Cvwj_5=sp(5,902:951);Cvwj_6=sp(6,902:951);
else;
   dev=(length(sp)-1)/19;
   Fson=sp(1,2:dev+1);
   Su_1=sp(1,dev+2:2*dev+1);Su_2=sp(2,dev+2:2*dev+1);Su_3=sp(3,dev+2:2*dev+1);Su_4=sp(4,dev+2:2*dev+1);Su_5=sp(5,dev+2:2*dev+1);Su_6=sp(6,dev+2:2*dev+1);
   Sv_1=sp(1,2*dev+2:3*dev+1);Sv_2=sp(2,2*dev+2:3*dev+1);Sv_3=sp(3,2*dev+2:3*dev+1);Sv_4=sp(4,2*dev+2:3*dev+1);Sv_5=sp(5,2*dev+2:3*dev+1);Sv_6=sp(6,2*dev+2:3*dev+1);
   Sw_1=sp(1,3*dev+2:4*dev+1);Sw_2=sp(2,3*dev+2:4*dev+1);Sw_3=sp(3,3*dev+2:4*dev+1);Sw_4=sp(4,3*dev+2:4*dev+1);Sw_5=sp(5,3*dev+2:4*dev+1);Sw_6=sp(6,3*dev+2:4*dev+1);
   St_1=sp(1,4*dev+2:5*dev+1);St_2=sp(2,4*dev+2:5*dev+1);St_3=sp(3,4*dev+2:5*dev+1);St_4=sp(4,4*dev+2:5*dev+1);St_5=sp(5,4*dev+2:5*dev+1);St_6=sp(6,4*dev+2:5*dev+1);
   Sq_1=sp(1,5*dev+2:6*dev+1);Sq_2=sp(2,5*dev+2:6*dev+1);Sq_3=sp(3,5*dev+2:6*dev+1);Sq_4=sp(4,5*dev+2:6*dev+1);Sq_5=sp(5,5*dev+2:6*dev+1);Sq_6=sp(6,5*dev+2:6*dev+1);
   So_1=sp(1,6*dev+2:7*dev+1);So_2=sp(2,6*dev+2:7*dev+1);So_3=sp(3,6*dev+2:7*dev+1);So_4=sp(4,6*dev+2:7*dev+1);So_5=sp(5,6*dev+2:7*dev+1);So_6=sp(6,6*dev+2:7*dev+1);
   Sc_1=sp(1,7*dev+2:8*dev+1);Sc_2=sp(2,7*dev+2:8*dev+1);Sc_3=sp(3,7*dev+2:8*dev+1);Sc_4=sp(4,7*dev+2:8*dev+1);Sc_5=sp(5,7*dev+2:8*dev+1);Sc_6=sp(6,7*dev+2:8*dev+1);
   Suj_1=sp(1,8*dev+2:9*dev+1);Suj_2=sp(2,8*dev+2:9*dev+1);Suj_3=sp(3,8*dev+2:9*dev+1);Suj_4=sp(4,8*dev+2:9*dev+1);Suj_5=sp(5,8*dev+2:9*dev+1);Suj_6=sp(6,8*dev+2:9*dev+1);
   Svj_1=sp(1,9*dev+2:10*dev+1);Svj_2=sp(2,9*dev+2:10*dev+1);Svj_3=sp(3,9*dev+2:10*dev+1);Svj_4=sp(4,9*dev+2:10*dev+1);Svj_5=sp(5,9*dev+2:10*dev+1);Svj_6=sp(6,9*dev+2:10*dev+1);
   Swj_1=sp(1,10*dev+2:11*dev+1);Swj_2=sp(2,10*dev+2:11*dev+1);Swj_3=sp(3,10*dev+2:11*dev+1);Swj_4=sp(4,10*dev+2:11*dev+1);Swj_5=sp(5,10*dev+2:11*dev+1);Swj_6=sp(6,10*dev+2:11*dev+1);
   Cuw_1=sp(1,11*dev+2:12*dev+1);Cuw_2=sp(2,11*dev+2:12*dev+1);Cuw_3=sp(3,11*dev+2:12*dev+1);Cuw_4=sp(4,11*dev+2:12*dev+1);Cuw_5=sp(5,11*dev+2:12*dev+1);Cuw_6=sp(6,11*dev+2:12*dev+1);
   Cvw_1=sp(1,12*dev+2:13*dev+1);Cvw_2=sp(2,12*dev+2:13*dev+1);Cvw_3=sp(3,12*dev+2:13*dev+1);Cvw_4=sp(4,12*dev+2:13*dev+1);Cvw_5=sp(5,12*dev+2:13*dev+1);Cvw_6=sp(6,12*dev+2:13*dev+1);
   Ctw_1=sp(1,13*dev+2:14*dev+1);Ctw_2=sp(2,13*dev+2:14*dev+1);Ctw_3=sp(3,13*dev+2:14*dev+1);Ctw_4=sp(4,13*dev+2:14*dev+1);Ctw_5=sp(5,13*dev+2:14*dev+1);Ctw_6=sp(6,13*dev+2:14*dev+1);
   Cqw_1=sp(1,14*dev+2:15*dev+1);Cqw_2=sp(2,14*dev+2:15*dev+1);Cqw_3=sp(3,14*dev+2:15*dev+1);Cqw_4=sp(4,14*dev+2:15*dev+1);Cqw_5=sp(5,14*dev+2:15*dev+1);Cqw_6=sp(6,14*dev+2:15*dev+1);
   Cow_1=sp(1,15*dev+2:16*dev+1);Cow_2=sp(2,15*dev+2:16*dev+1);Cow_3=sp(3,15*dev+2:16*dev+1);Cow_4=sp(4,15*dev+2:16*dev+1);Cow_5=sp(5,15*dev+2:16*dev+1);Cow_6=sp(6,15*dev+2:16*dev+1);
   Ccw_1=sp(1,16*dev+2:17*dev+1);Ccw_2=sp(2,16*dev+2:17*dev+1);Ccw_3=sp(3,16*dev+2:17*dev+1);Ccw_4=sp(4,16*dev+2:17*dev+1);Ccw_5=sp(5,16*dev+2:17*dev+1);Ccw_6=sp(6,16*dev+2:17*dev+1);
   Cuwj_1=sp(1,17*dev+2:18*dev+1);Cuwj_2=sp(2,17*dev+2:18*dev+1);Cuwj_3=sp(3,17*dev+2:18*dev+1);Cuwj_4=sp(4,17*dev+2:18*dev+1);Cuwj_5=sp(5,17*dev+2:18*dev+1);Cuwj_6=sp(6,17*dev+2:18*dev+1);
   Cvwj_1=sp(1,18*dev+2:19*dev+1);Cvwj_2=sp(2,18*dev+2:19*dev+1);Cvwj_3=sp(3,18*dev+2:19*dev+1);Cvwj_4=sp(4,18*dev+2:19*dev+1);Cvwj_5=sp(5,18*dev+2:19*dev+1);Cvwj_6=sp(6,18*dev+2:19*dev+1);
end;

St_1=St_1-0.01.*Tbar_1.*Sw_1.*(sin(2.*pi.*Fson.*0.01).^2);
St_2=St_2-0.01.*Tbar_2.*Sw_2.*(sin(2.*pi.*Fson.*0.01).^2);
St_3=St_3-0.01.*Tbar_3.*Sw_3.*(sin(2.*pi.*Fson.*0.01).^2);
St_4=St_4-0.01.*Tbar_4.*Sw_4.*(sin(2.*pi.*Fson.*0.01).^2);
St_5=St_5-0.01.*Tbar_5.*Sw_5.*(sin(2.*pi.*Fson.*0.01).^2);
St_6=St_6-0.01.*Tbar_6.*Sw_6.*(sin(2.*pi.*Fson.*0.01).^2);

%Apply Wyngaard and Clifford Correction to the Structure Function Parameters

F1_1= 1 - (uu_1 / 9 + 2 * vv_1 / 3 + 2 * ww_1 / 3) / Ubar_1 / Ubar_1;
F1_2= 1 - (uu_2 / 9 + 2 * vv_2 / 3 + 2 * ww_2 / 3) / Ubar_2 / Ubar_2;
F1_3= 1 - (uu_3 / 9 + 2 * vv_3 / 3 + 2 * ww_3 / 3) / Ubar_3 / Ubar_3;
F1_4= 1 - (uu_4 / 9 + 2 * vv_4 / 3 + 2 * ww_4 / 3) / Ubar_4 / Ubar_4;
F1_5= 1 - (uu_5 / 9 + 2 * vv_5 / 3 + 2 * ww_5 / 3) / Ubar_5 / Ubar_5;
F1_6= 1 - (uu_6 / 9 + 2 * vv_6 / 3 + 2 * ww_6 / 3) / Ubar_6 / Ubar_6;

F2_1= 1 - (uu_1 / 9 + vv_1 / 12 + ww_1 / 3) / Ubar_1 / Ubar_1;
F2_2= 1 - (uu_2 / 9 + vv_2 / 12 + ww_2 / 3) / Ubar_2 / Ubar_2;
F2_3= 1 - (uu_3 / 9 + vv_3 / 12 + ww_3 / 3) / Ubar_3 / Ubar_3;
F2_4= 1 - (uu_4 / 9 + vv_4 / 12 + ww_4 / 3) / Ubar_4 / Ubar_4;
F2_5= 1 - (uu_5 / 9 + vv_5 / 12 + ww_5 / 3) / Ubar_5 / Ubar_5;
F2_6= 1 - (uu_6 / 9 + vv_6 / 12 + ww_6 / 3) / Ubar_6 / Ubar_6;

F3_1= 1 - (uu_1 / 9 + vv_1 / 3 + 2 * ww_1 / 3) / Ubar_1 / Ubar_1;
F3_2= 1 - (uu_2 / 9 + vv_2 / 3 + 2 * ww_2 / 3) / Ubar_2 / Ubar_2;
F3_3= 1 - (uu_3 / 9 + vv_3 / 3 + 2 * ww_3 / 3) / Ubar_3 / Ubar_3;
F3_4= 1 - (uu_4 / 9 + vv_4 / 3 + 2 * ww_4 / 3) / Ubar_4 / Ubar_4;
F3_5= 1 - (uu_5 / 9 + vv_5 / 3 + 2 * ww_5 / 3) / Ubar_5 / Ubar_5;
F3_6= 1 - (uu_6 / 9 + vv_6 / 3 + 2 * ww_6 / 3) / Ubar_6 / Ubar_6;

fminU=min(find(Fson>.6));if fminU<1,fminU=1,end;
fmaxU=max(find(Fson<3.5));if fmaxU>length(Fson),fmaxU=length(Fson);end;

%cS=4*2/20;
cS=4;           %PSD2 and CSD2 should take care of the factor 2/20

if fminU>fmaxU,fminU=fmaxU-4;end;

Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_1)^(2/3))*Su_1(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cu2_1_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_1)^(2/3))*Su_1(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_1)^(2/3))*Su_1(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cu2_1_2=exp(Zpoly(5));
end;
Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_2)^(2/3))*Su_2(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cu2_2_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_2)^(2/3))*Su_2(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_2)^(2/3))*Su_2(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cu2_2_2=exp(Zpoly(5));
end;
Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_3)^(2/3))*Su_3(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cu2_3_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_3)^(2/3))*Su_3(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_3)^(2/3))*Su_3(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cu2_3_2=exp(Zpoly(5));
end;
Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_4)^(2/3))*Su_4(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cu2_4_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_4)^(2/3))*Su_4(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_4)^(2/3))*Su_4(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cu2_4_2=exp(Zpoly(5));
end;
Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_5)^(2/3))*Su_5(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cu2_5_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_5)^(2/3))*Su_5(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_5)^(2/3))*Su_5(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cu2_5_2=exp(Zpoly(5));
end;
Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_6)^(2/3))*Su_6(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cu2_6_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_6)^(2/3))*Su_6(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_6)^(2/3))*Su_6(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cu2_6_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_1)^(2/3))*Sw_1(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cw2_1_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_1)^(2/3))*Sw_1(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_1)^(2/3))*Sw_1(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cw2_1_2=exp(Zpoly(5));
end;
Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_2)^(2/3))*Sw_2(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cw2_2_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_2)^(2/3))*Sw_2(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_2)^(2/3))*Sw_2(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cw2_2_2=exp(Zpoly(5));
end;
Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_3)^(2/3))*Sw_3(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cw2_3_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_3)^(2/3))*Sw_3(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_3)^(2/3))*Sw_3(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cw2_3_2=exp(Zpoly(5));
end;
Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_4)^(2/3))*Sw_4(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cw2_4_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_4)^(2/3))*Sw_4(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_4)^(2/3))*Sw_4(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cw2_4_2=exp(Zpoly(5));
end;
Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_5)^(2/3))*Sw_5(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cw2_5_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_5)^(2/3))*Sw_5(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_5)^(2/3))*Sw_5(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cw2_5_2=exp(Zpoly(5));
end;
Zpoly=polyfit(log(Fson(fminU:fmaxU)),log(cS*((2*pi/Ustr_6)^(2/3))*Sw_6(fminU:fmaxU).*(Fson(fminU:fmaxU).^(2/3))),4);
if Zpoly(4)<0.25,
   Cw2_6_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminU+plus+4==fmaxU,
         if fmaxU<4;fmaxU=4;end;
         Zpoly=polyfit(log(Fson(fmaxU-4:fmaxU)),log(cS*((2*pi/Ustr_6)^(2/3))*Sw_6(fmaxU-4:fmaxU).*(Fson(fmaxU-4:fmaxU).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminU+plus:fmaxU)),log(cS*((2*pi/Ustr_6)^(2/3))*Sw_6(fminU+plus:fmaxU).*(Fson(fminU+plus:fmaxU).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cw2_6_2=exp(Zpoly(5));
end;

fminT=min(find(Fson>.35));if fminT<1,fminT=1,end;
fmaxT=max(find(Fson<3));if fmaxT>length(Fson),fmaxT=length(Fson);end;

%cS=4*2/20;
cS=4;           %PSD2 and CSD2 should take care of the factor 2/20

if fminT>fmaxT,fminT=fmaxT-4;end;

Zpoly=polyfit(log(Fson(fminT:fmaxT)),log(cS*((2*pi/Ustr_1)^(2/3))*St_1(fminT:fmaxT).*(Fson(fminT:fmaxT).^(2/3))),4);
if Zpoly(4)<0.25,
   Ct2_1_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminT+plus+4==fmaxT,
         if fmaxT<4;fmaxT=4;end;
         Zpoly=polyfit(log(Fson(fmaxT-4:fmaxT)),log(cS*((2*pi/Ustr_1)^(2/3))*St_1(fmaxT-4:fmaxT).*(Fson(fmaxT-4:fmaxT).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminT+plus:fmaxT)),log(cS*((2*pi/Ustr_1)^(2/3))*St_1(fminT+plus:fmaxT).*(Fson(fminT+plus:fmaxT).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Ct2_1_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminT:fmaxT)),log(cS*((2*pi/Ustr_2)^(2/3))*St_2(fminT:fmaxT).*(Fson(fminT:fmaxT).^(2/3))),4);
if Zpoly(4)<0.25,
   Ct2_2_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminT+plus+4==fmaxT,
         if fmaxT<4;fmaxT=4;end;
         Zpoly=polyfit(log(Fson(fmaxT-4:fmaxT)),log(cS*((2*pi/Ustr_2)^(2/3))*St_2(fmaxT-4:fmaxT).*(Fson(fmaxT-4:fmaxT).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminT+plus:fmaxT)),log(cS*((2*pi/Ustr_2)^(2/3))*St_2(fminT+plus:fmaxT).*(Fson(fminT+plus:fmaxT).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Ct2_2_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminT:fmaxT)),log(cS*((2*pi/Ustr_3)^(2/3))*St_3(fminT:fmaxT).*(Fson(fminT:fmaxT).^(2/3))),4);
if Zpoly(4)<0.25,
   Ct2_3_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminT+plus+4==fmaxT,
         if fmaxT<4;fmaxT=4;end;
         Zpoly=polyfit(log(Fson(fmaxT-4:fmaxT)),log(cS*((2*pi/Ustr_3)^(2/3))*St_3(fmaxT-4:fmaxT).*(Fson(fmaxT-4:fmaxT).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminT+plus:fmaxT)),log(cS*((2*pi/Ustr_3)^(2/3))*St_3(fminT+plus:fmaxT).*(Fson(fminT+plus:fmaxT).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Ct2_3_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminT:fmaxT)),log(cS*((2*pi/Ustr_4)^(2/3))*St_4(fminT:fmaxT).*(Fson(fminT:fmaxT).^(2/3))),4);
if Zpoly(4)<0.25,
   Ct2_4_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminT+plus+4==fmaxT,
         if fmaxT<4;fmaxT=4;end;
         Zpoly=polyfit(log(Fson(fmaxT-4:fmaxT)),log(cS*((2*pi/Ustr_4)^(2/3))*St_4(fmaxT-4:fmaxT).*(Fson(fmaxT-4:fmaxT).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminT+plus:fmaxT)),log(cS*((2*pi/Ustr_4)^(2/3))*St_4(fminT+plus:fmaxT).*(Fson(fminT+plus:fmaxT).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Ct2_4_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminT:fmaxT)),log(cS*((2*pi/Ustr_5)^(2/3))*St_5(fminT:fmaxT).*(Fson(fminT:fmaxT).^(2/3))),4);
if Zpoly(4)<0.25,
   Ct2_5_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminT+plus+4==fmaxT,
         if fmaxT<4;fmaxT=4;end;
         Zpoly=polyfit(log(Fson(fmaxT-4:fmaxT)),log(cS*((2*pi/Ustr_5)^(2/3))*St_5(fmaxT-4:fmaxT).*(Fson(fmaxT-4:fmaxT).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminT+plus:fmaxT)),log(cS*((2*pi/Ustr_5)^(2/3))*St_5(fminT+plus:fmaxT).*(Fson(fminT+plus:fmaxT).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Ct2_5_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminT:fmaxT)),log(cS*((2*pi/Ustr_6)^(2/3))*St_6(fminT:fmaxT).*(Fson(fminT:fmaxT).^(2/3))),4);
if Zpoly(4)<0.25,
   Ct2_6_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminT+plus+4==fmaxT,
         if fmaxT<4;fmaxT=4;end;
         Zpoly=polyfit(log(Fson(fmaxT-4:fmaxT)),log(cS*((2*pi/Ustr_6)^(2/3))*St_6(fmaxT-4:fmaxT).*(Fson(fmaxT-4:fmaxT).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminT+plus:fmaxT)),log(cS*((2*pi/Ustr_6)^(2/3))*St_6(fminT+plus:fmaxT).*(Fson(fminT+plus:fmaxT).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Ct2_6_2=exp(Zpoly(5));
end;

fminO=min(find(Fson>0.7));if fminO<1,fminO=1,end;
fmaxO=max(find(Fson<3.6));if fmaxO>length(Fson),fmaxO=length(Fson);end;

%cO=4*2/20;
cO=4;           %PSD2 and CSD2 should take care of the factor 2/20

if fminO>fmaxO,fminO=fmaxO-4;end

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_1)^(2/3))*Sq_1(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cq2_1_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_1)^(2/3))*Sq_1(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_1)^(2/3))*Sq_1(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cq2_1_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_2)^(2/3))*Sq_2(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cq2_2_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_2)^(2/3))*Sq_2(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_2)^(2/3))*Sq_2(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cq2_2_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_3)^(2/3))*Sq_3(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cq2_3_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_3)^(2/3))*Sq_3(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_3)^(2/3))*Sq_3(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cq2_3_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_4)^(2/3))*Sq_4(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cq2_4_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_4)^(2/3))*Sq_4(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_4)^(2/3))*Sq_4(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cq2_4_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_5)^(2/3))*Sq_5(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cq2_5_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_5)^(2/3))*Sq_5(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_5)^(2/3))*Sq_5(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cq2_5_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_6)^(2/3))*Sq_6(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cq2_6_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_6)^(2/3))*Sq_6(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_6)^(2/3))*Sq_6(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cq2_6_2=exp(Zpoly(5));
end;

fminO=min(find(Fson>0.7));if fminO<1,fminO=1,end;
fmaxO=max(find(Fson<3.6));if fmaxO>length(Fson),fmaxO=length(Fson);end;

%cO=4*2/20;
cO=4;           %PSD2 and CSD2 should take care of the factor 2/20

if fminO>fmaxO,fminO=fmaxO-4;end

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_1)^(2/3))*So_1(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Co2_1_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_1)^(2/3))*So_1(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_1)^(2/3))*So_1(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Co2_1_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_2)^(2/3))*So_2(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Co2_2_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_2)^(2/3))*So_2(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_2)^(2/3))*So_2(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Co2_2_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_3)^(2/3))*So_3(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Co2_3_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_3)^(2/3))*So_3(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_3)^(2/3))*So_3(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Co2_3_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_4)^(2/3))*So_4(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Co2_4_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_4)^(2/3))*So_4(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_4)^(2/3))*So_4(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Co2_4_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_5)^(2/3))*So_5(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Co2_5_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_5)^(2/3))*So_5(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_5)^(2/3))*So_5(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Co2_5_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_6)^(2/3))*So_6(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Co2_6_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_6)^(2/3))*So_6(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_6)^(2/3))*So_6(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Co2_6_2=exp(Zpoly(5));
end;

fminO=min(find(Fson>0.7));if fminO<1,fminO=1,end;
fmaxO=max(find(Fson<3.6));if fmaxO>length(Fson),fmaxO=length(Fson);end;

%cO=4*2/20;
cO=4;           %PSD2 and CSD2 should take care of the factor 2/20

if fminO>fmaxO,fminO=fmaxO-4;end

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_1)^(2/3))*Sc_1(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cc2_1_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_1)^(2/3))*Sc_1(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_1)^(2/3))*Sc_1(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cc2_1_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_2)^(2/3))*Sc_2(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cc2_2_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_2)^(2/3))*Sc_2(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_2)^(2/3))*Sc_2(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cc2_2_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_3)^(2/3))*Sc_3(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cc2_3_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_3)^(2/3))*Sc_3(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_3)^(2/3))*Sc_3(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cc2_3_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_4)^(2/3))*Sc_4(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cc2_4_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_4)^(2/3))*Sc_4(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_4)^(2/3))*Sc_4(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cc2_4_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_5)^(2/3))*Sc_5(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cc2_5_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_5)^(2/3))*Sc_5(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_5)^(2/3))*Sc_5(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cc2_5_2=exp(Zpoly(5));
end;

Zpoly=polyfit(log(Fson(fminO:fmaxO)),log(cO*((2*pi/Ustr_6)^(2/3))*Sc_6(fminO:fmaxO).*(Fson(fminO:fmaxO).^(2/3))),4);
if Zpoly(4)<0.25,
   Cc2_6_2=exp(Zpoly(5));
else,
   plus=0;
   while 1
      zold=Zpoly(4);
      plus=plus+1;
      if fminO+plus+4==fmaxO,
         if fmaxO<4;fmaxO=4;end;
         Zpoly=polyfit(log(Fson(fmaxO-4:fmaxO)),log(cO*((2*pi/Ustr_6)^(2/3))*Sc_6(fmaxO-4:fmaxO).*(Fson(fmaxO-4:fmaxO).^(2/3))),4);
         break;
      end;            
      Zpoly=polyfit(log(Fson(fminO+plus:fmaxO)),log(cO*((2*pi/Ustr_6)^(2/3))*Sc_6(fminO+plus:fmaxO).*(Fson(fminO+plus:fmaxO).^(2/3))),4);
      if Zpoly(4)>zold,break,end
   end;
   Cc2_6_2=exp(Zpoly(5));
end;

figure;loglog(Fson,Fson.*Su_1,Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_1_2*((2*pi/Ustr_1).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'g');title(['Cu^2_1   ',ddd,'   ',hhh]);
figure;loglog(Fson,Fson.*Su_2,Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_2_2*((2*pi/Ustr_2).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'g');title(['Cu^2_2   ',ddd,'   ',hhh]);
figure;loglog(Fson,Fson.*Su_3,Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_3_2*((2*pi/Ustr_3).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'g');title(['Cu^2_3   ',ddd,'   ',hhh]);
figure;loglog(Fson,Fson.*Su_4,Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_4_2*((2*pi/Ustr_4).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'g');title(['Cu^2_4   ',ddd,'   ',hhh]);
figure;loglog(Fson,Fson.*Su_5,Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_5_2*((2*pi/Ustr_5).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'g');title(['Cu^2_5   ',ddd,'   ',hhh]);
figure;loglog(Fson,Fson.*Su_6,Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_6_2*((2*pi/Ustr_6).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'g');title(['Cu^2_6   ',ddd,'   ',hhh]);
%figure;loglog(Fson,Fson.*Sw_1,Fson(fminU:fmaxU),Fson(fminU:fmaxU).*Cw2_1_2*((2*pi/Ustr_1).^(-2/3))./cS.*Fson(fminU:fmaxU).^(-5/3));title('Cw^2_1');
%figure;loglog(Fson,Fson.*Sw_2,Fson(fminU:fmaxU),Fson(fminU:fmaxU).*Cw2_2_2*((2*pi/Ustr_2).^(-2/3))./cS.*Fson(fminU:fmaxU).^(-5/3));title('Cw^2_2');
%figure;loglog(Fson,Fson.*Sw_3,Fson(fminU:fmaxU),Fson(fminU:fmaxU).*Cw2_3_2*((2*pi/Ustr_3).^(-2/3))./cS.*Fson(fminU:fmaxU).^(-5/3));title('Cw^2_3');
%figure;loglog(Fson,Fson.*Sw_4,Fson(fminU:fmaxU),Fson(fminU:fmaxU).*Cw2_4_2*((2*pi/Ustr_4).^(-2/3))./cS.*Fson(fminU:fmaxU).^(-5/3));title('Cw^2_4');
%figure;loglog(Fson,Fson.*Sw_5,Fson(fminU:fmaxU),Fson(fminU:fmaxU).*Cw2_5_2*((2*pi/Ustr_5).^(-2/3))./cS.*Fson(fminU:fmaxU).^(-5/3));title('Cw^2_5');
%figure;loglog(Fson,Fson.*Sw_6,Fson(fminU:fmaxU),Fson(fminU:fmaxU).*Cw2_6_2*((2*pi/Ustr_6).^(-2/3))./cS.*Fson(fminU:fmaxU).^(-5/3));title('Cw^2_6');
figure;loglog(Fson,Fson.*St_1,Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_1_2*((2*pi/Ustr_1).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'g');title(['Ct^2_1   ',ddd,'   ',hhh]);
figure;loglog(Fson,Fson.*St_2,Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_2_2*((2*pi/Ustr_2).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'g');title(['Ct^2_2   ',ddd,'   ',hhh]);
figure;loglog(Fson,Fson.*St_3,Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_3_2*((2*pi/Ustr_3).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'g');title(['Ct^2_3   ',ddd,'   ',hhh]);
figure;loglog(Fson,Fson.*St_4,Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_4_2*((2*pi/Ustr_4).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'g');title(['Ct^2_4   ',ddd,'   ',hhh]);
figure;loglog(Fson,Fson.*St_5,Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_5_2*((2*pi/Ustr_5).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'g');title(['Ct^2_5   ',ddd,'   ',hhh]);
figure;loglog(Fson,Fson.*St_6,Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_6_2*((2*pi/Ustr_6).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'g');title(['Ct^2_6   ',ddd,'   ',hhh]);
%figure;loglog(Fson,Fson.*Sq_1,Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_1_2*((2*pi/Ustr_1).^(-2/3))./cO.*Fson(fminO-12:fmaxO+7).^(-5/3),'g');title(['Cq^2_1   ',ddd,'   ',hhh]);
%figure;loglog(Fson,Fson.*Sq_2,Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_2_2*((2*pi/Ustr_2).^(-2/3))./cO.*Fson(fminO-12:fmaxO+7).^(-5/3),'g');title(['Cq^2_2   ',ddd,'   ',hhh]);
%figure;loglog(Fson,Fson.*Sq_3,Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_3_2*((2*pi/Ustr_3).^(-2/3))./cO.*Fson(fminO-12:fmaxO+7).^(-5/3),'g');title(['Cq^2_3   ',ddd,'   ',hhh]);
%figure;loglog(Fson,Fson.*Sq_4,Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_4_2*((2*pi/Ustr_4).^(-2/3))./cO.*Fson(fminO-12:fmaxO+7).^(-5/3),'g');title(['Cq^2_4   ',ddd,'   ',hhh]);
%figure;loglog(Fson,Fson.*Sq_5,Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_5_2*((2*pi/Ustr_5).^(-2/3))./cO.*Fson(fminO-12:fmaxO+7).^(-5/3),'g');title(['Cq^2_5   ',ddd,'   ',hhh]);
%figure;loglog(Fson,Fson.*Sq_6,Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_6_2*((2*pi/Ustr_6).^(-2/3))./cO.*Fson(fminO-12:fmaxO+7).^(-5/3),'g');title(['Cq^2_6   ',ddd,'   ',hhh]);

%   Apply Wyngaard and Clifford Correction to the Structure Function Parameters
Cu2_1_2=Cu2_1_2/F1_1;Cu2_2_2=Cu2_2_2/F1_2;Cu2_3_2=Cu2_3_2/F1_3;Cu2_4_2=Cu2_4_2/F1_4;Cu2_5_2=Cu2_5_2/F1_5;Cu2_6_2=Cu2_6_2/F1_6;
Ct2_1_2=Ct2_1_2/F2_1;Ct2_2_2=Ct2_2_2/F2_2;Ct2_3_2=Ct2_3_2/F2_3;Ct2_4_2=Ct2_4_2/F2_4;Ct2_5_2=Ct2_5_2/F2_5;Ct2_6_2=Ct2_6_2/F2_6;
Cq2_1_2=Cq2_1_2/F2_1;Cq2_2_2=Cq2_2_2/F2_2;Cq2_3_2=Cq2_3_2/F2_3;Cq2_4_2=Cq2_4_2/F2_4;Cq2_5_2=Cq2_5_2/F2_5;Cq2_6_2=Cq2_6_2/F2_6;
Cc2_1_2=Cc2_1_2/F2_1;Cc2_2_2=Cc2_2_2/F2_2;Cc2_3_2=Cc2_3_2/F2_3;Cc2_4_2=Cc2_4_2/F2_4;Cc2_5_2=Cc2_5_2/F2_5;Cc2_6_2=Cc2_6_2/F2_6;
Co2_1_2=Co2_1_2/F2_1;Co2_2_2=Co2_2_2/F2_2;Co2_3_2=Co2_3_2/F2_3;Co2_4_2=Co2_4_2/F2_4;Co2_5_2=Co2_5_2/F2_5;Co2_6_2=Co2_6_2/F2_6;

y=yship_1;x=xship_1;Cu2=Cu2_1_2;Ct2=Ct2_1_2;Cq2=Cq2_1_2;Cc2=Cc2_1_2;Co2=Co2_1_2;Q=Qbar_1;idiss;usid_1_2=us0;tsid_1_2=ts_ib;qsid_1_2=qs_ib;osid_1_2=os_ib;csid_1_2=cs_ib;Lid_1_2=z_u/zet;
y=yship_2;x=xship_2;Cu2=Cu2_2_2;Ct2=Ct2_2_2;Cq2=Cq2_2_2;Cc2=Cc2_2_2;Co2=Co2_2_2;Q=Qbar_2;idiss;usid_2_2=us0;tsid_2_2=ts_ib;qsid_2_2=qs_ib;osid_2_2=os_ib;csid_2_2=cs_ib;Lid_2_2=z_u/zet;
y=yship_3;x=xship_3;Cu2=Cu2_3_2;Ct2=Ct2_3_2;Cq2=Cq2_3_2;Cc2=Cc2_3_2;Co2=Co2_3_2;Q=Qbar_3;idiss;usid_3_2=us0;tsid_3_2=ts_ib;qsid_3_2=qs_ib;osid_3_2=os_ib;csid_3_2=cs_ib;Lid_3_2=z_u/zet;
y=yship_4;x=xship_4;Cu2=Cu2_4_2;Ct2=Ct2_4_2;Cq2=Cq2_4_2;Cc2=Cc2_4_2;Co2=Co2_4_2;Q=Qbar_4;idiss;usid_4_2=us0;tsid_4_2=ts_ib;qsid_4_2=qs_ib;osid_4_2=os_ib;csid_4_2=cs_ib;Lid_4_2=z_u/zet;
y=yship_5;x=xship_5;Cu2=Cu2_5_2;Ct2=Ct2_5_2;Cq2=Cq2_5_2;Cc2=Cc2_5_2;Co2=Co2_5_2;Q=Qbar_5;idiss;usid_5_2=us0;tsid_5_2=ts_ib;qsid_5_2=qs_ib;osid_5_2=os_ib;csid_5_2=cs_ib;Lid_5_2=z_u/zet;
y=yship_6;x=xship_6;Cu2=Cu2_6_2;Ct2=Ct2_6_2;Cq2=Cq2_6_2;Cc2=Cc2_6_2;Co2=Co2_6_2;Q=Qbar_6;idiss;usid_6_2=us0;tsid_6_2=ts_ib;qsid_6_2=qs_ib;osid_6_2=os_ib;csid_6_2=cs_ib;Lid_6_2=z_u/zet;

%y_y=[y_1 Ubar_1 Tbar_1 Tsea_1 Qbar_1 wu_1(1,2) wv_1(1,2) wt_1(1,2) wa_1(1,2) wh_1(1,2) rho_1 stdC_1 stdA_1 medC_1 medA_1 Ss_1 Sc_1 Sp_1 rain_1
%     y_2 Ubar_2 Tbar_2 Tsea_2 Qbar_2 wu_2(1,2) wv_2(1,2) wt_2(1,2) wa_2(1,2) wh_2(1,2) rho_2 stdC_2 stdA_2 medC_2 medA_2 Ss_2 Sc_2 Sp_2 rain_2
%     y_3 Ubar_3 Tbar_3 Tsea_3 Qbar_3 wu_3(1,2) wv_3(1,2) wt_3(1,2) wa_3(1,2) wh_3(1,2) rho_3 stdC_3 stdA_3 medC_3 medA_3 Ss_3 Sc_3 Sp_3 rain_3
%     y_4 Ubar_4 Tbar_4 Tsea_4 Qbar_4 wu_4(1,2) wv_4(1,2) wt_4(1,2) wa_4(1,2) wh_4(1,2) rho_4 stdC_4 stdA_4 medC_4 medA_4 Ss_4 Sc_4 Sp_4 rain_4
%     y_5 Ubar_5 Tbar_5 Tsea_5 Qbar_5 wu_5(1,2) wv_5(1,2) wt_5(1,2) wa_5(1,2) wh_5(1,2) rho_5 stdC_5 stdA_5 medC_5 medA_5 Ss_5 Sc_5 Sp_5 rain_5
%     y_6 Ubar_6 Tbar_6 Tsea_6 Qbar_6 wu_6(1,2) wv_6(1,2) wt_6(1,2) wa_6(1,2) wh_6(1,2) rho_6 stdC_6 stdA_6 medC_6 medA_6 Ss_6 Sc_6 Sp_6 rain_6];

clear Su_1 Sw_1 St_1 Sq_1 So_1 Sc_1 Ch_1 Ch_2 Ch_3 Ch_4 Ch_5 Ch_6 Chs_1 Chs_2 Chs_3 Chs_4 
clear Chs_5 Chs_6 Cq2 Ct2 Cu2 F Fo Ct_1 Ct_2 Ct_3 Ct_4 Ct_5 Ct_6 Cts_1 Cts_2 Cts_3 Cts_4 
clear Cts_5 Cts_6 Cu_1 Cu_2 Cu_3 Cu_4 Cu_5 Cu_6 Cus_1 Cus_2 Cus_3 Cus_4 Cus_5 Cus_6 Cv_1 
clear Cv_2 Cv_3 Cv_4 Cv_5 Cv_6 Cvs_1 Cvs_2 Cvs_3 Cvs_4 Cvs_5 Cvs_6 Cw_1 Cw_2 Cw_3 Cw_4 
clear Cw_5 Cw_6 Cws_1 Cws_2 Cws_3 Cws_4 Cws_5 Cws_6 Esat_1 Esat_2 Esat_3 Esat_4 Esat_5 
clear Esat_6 Q_1 Q_2 Q_3 Q_4 Q_5 Q_6 L LongIR1 LongIR2 P Q Qsea_1 Qsea_2 Qsea_3 Qsea_4 
clear Qsea_5 Qsea_6 RHv Solar1 Solar2 T TT Tairv Tsea Tsea_snake Tv Us alphau c Uid_1 
clear Uid_2 Uid_3 Uid_4 Uid_5 Uid_6 c_coeff cog daytest fmax g head hourtest iii lat long 
clear qs0 medA_1 medA_2 medA_3 medA_4 medA_5 medA_6 stdA_1 stdA_2 stdA_3 stdA_4 stdA_5 
clear stdA_6 qs_ib rho sog ts0 u_id us0 us_ib vkon x zet z zi x_1 x_2 x_3 x_4 x_5 x_6 zq 
clear zt zu zzz Qs Qs_10 RH F1_1 F1_2 F1_3 F1_4 F1_5 F1_6 F2_1 F2_2 F2_3 F2_4 F2_5 F2_6 
clear F3_1 F3_2 F3_3 F3_4 F3_5 F3_6

xmin=1000000;xmax=0;ymin=100000;ymax=0;for ii=1:6;figure(ii);a=axis;if xmin>a(1),xmin=a(1);end;if xmax<a(2),xmax=a(2);end;if ymin>a(3),ymin=a(3);end;if ymax<a(4),ymax=a(4);end;end;
for ii=1:6;figure(ii);axis([xmin xmax ymin ymax]);end;

xmin=1000000;xmax=0;ymin=100000;ymax=0;for ii=7:12;figure(ii);a=axis;if xmin>a(1),xmin=a(1);end;if xmax<a(2),xmax=a(2);end;if ymin>a(3),ymin=a(3);end;if ymax<a(4),ymax=a(4);end;end;
for ii=7:12;figure(ii);axis([xmin xmax ymin*10 ymax]);end;

%xmin=1000000;xmax=0;ymin=100000;ymax=0;for ii=13:18;figure(ii);a=axis;if xmin>a(1),xmin=a(1);end;if xmax<a(2),xmax=a(2);end;if ymin>a(3),ymin=a(3);end;if ymax<a(4),ymax=a(4);end;end;
%for ii=13:18;figure(ii);axis([xmin xmax ymin*10 ymax]);end;

Uold=[Cu2_1_2 Cu2_2_2 Cu2_3_2 Cu2_4_2 Cu2_5_2 Cu2_6_2];
Told=[Ct2_1_2 Ct2_2_2 Ct2_3_2 Ct2_4_2 Ct2_5_2 Ct2_6_2];
Qold=[Cq2_1_2 Cq2_2_2 Cq2_3_2 Cq2_4_2 Cq2_5_2 Cq2_6_2];
uold=[usid_1_2 usid_2_2 usid_3_2 usid_4_2 usid_5_2 usid_6_2];
told=[tsid_1_2 tsid_2_2 tsid_3_2 tsid_4_2 tsid_5_2 tsid_6_2];
qold=[qsid_1_2 qsid_2_2 qsid_3_2 qsid_4_2 qsid_5_2 qsid_6_2];

figure(1);hold
while 1
   dcheck=input('up? down? okay? bad?  ','s')
   delta=0.003;
   if dcheck=='u',
      Cu2_1_2=Cu2_1_2+delta;
   elseif dcheck=='U',
      Cu2_1_2=Cu2_1_2+2*delta;
   elseif dcheck=='d',
      Cu2_1_2=Cu2_1_2-delta;
   elseif dcheck=='D',
      Cu2_1_2=Cu2_1_2-3*delta;
   elseif dcheck=='b',
      Cu2_1_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(1);loglog(Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_1_2*((2*pi/Ustr_1).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'r');
end;

figure(2);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.003;
   if dcheck=='u',
      Cu2_2_2=Cu2_2_2+delta;
   elseif dcheck=='U',
      Cu2_2_2=Cu2_2_2+2*delta;
   elseif dcheck=='d',
      Cu2_2_2=Cu2_2_2-delta;
   elseif dcheck=='D',
      Cu2_2_2=Cu2_2_2-3*delta;
   elseif dcheck=='b',
      Cu2_2_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(2);loglog(Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_2_2*((2*pi/Ustr_2).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'r');
end;

figure(3);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.003;
   if dcheck=='u',
      Cu2_3_2=Cu2_3_2+delta;
   elseif dcheck=='U',
      Cu2_3_2=Cu2_3_2+2*delta;
   elseif dcheck=='d',
      Cu2_3_2=Cu2_3_2-delta;
   elseif dcheck=='D',
      Cu2_3_2=Cu2_3_2-3*delta;
   elseif dcheck=='b',
      Cu2_3_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(3);loglog(Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_3_2*((2*pi/Ustr_3).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'r');
end;

figure(4);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.003;
   if dcheck=='u',
      Cu2_4_2=Cu2_4_2+delta;
   elseif dcheck=='U',
      Cu2_4_2=Cu2_4_2+2*delta;
   elseif dcheck=='d',
      Cu2_4_2=Cu2_4_2-delta;
   elseif dcheck=='D',
      Cu2_4_2=Cu2_4_2-3*delta;
   elseif dcheck=='b',
      Cu2_4_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(4);loglog(Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_4_2*((2*pi/Ustr_4).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'r');
end;

figure(5);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.003;
   if dcheck=='u',
      Cu2_5_2=Cu2_5_2+delta;
   elseif dcheck=='U',
      Cu2_5_2=Cu2_5_2+2*delta;
   elseif dcheck=='d',
      Cu2_5_2=Cu2_5_2-delta;
   elseif dcheck=='D',
      Cu2_5_2=Cu2_5_2-3*delta;
   elseif dcheck=='b',
      Cu2_5_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(5);loglog(Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_5_2*((2*pi/Ustr_5).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'r');
end;

figure(6);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.003;
   if dcheck=='u',
      Cu2_6_2=Cu2_6_2+delta;
   elseif dcheck=='U',
      Cu2_6_2=Cu2_6_2+2*delta;
   elseif dcheck=='d',
      Cu2_6_2=Cu2_6_2-delta;
   elseif dcheck=='D',
      Cu2_6_2=Cu2_6_2-3*delta;
   elseif dcheck=='b',
      Cu2_6_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(6);loglog(Fson(fminU-10:fmaxU+7),Fson(fminU-10:fmaxU+7).*Cu2_6_2*((2*pi/Ustr_6).^(-2/3))./cS.*Fson(fminU-10:fmaxU+7).^(-5/3),'r');
end;

figure(7);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.0002;
   if dcheck=='u',
      Ct2_1_2=Ct2_1_2+delta;
   elseif dcheck=='U',
      Ct2_1_2=Ct2_1_2+2*delta;
   elseif dcheck=='d',
      Ct2_1_2=Ct2_1_2-delta;
   elseif dcheck=='D',
      Ct2_1_2=Ct2_1_2-3*delta;
   elseif dcheck=='b',
      Ct2_1_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(7);loglog(Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_1_2*((2*pi/Ustr_1).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'r');
end;

figure(8);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.0002;
   if dcheck=='u',
      Ct2_2_2=Ct2_2_2+delta;
   elseif dcheck=='U',
      Ct2_2_2=Ct2_2_2+2*delta;
   elseif dcheck=='d',
      Ct2_2_2=Ct2_2_2-delta;
   elseif dcheck=='D',
      Ct2_2_2=Ct2_2_2-3*delta;
   elseif dcheck=='b',
      Ct2_2_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(8);loglog(Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_2_2*((2*pi/Ustr_2).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'r');
end;

figure(9);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.0002;
   if dcheck=='u',
      Ct2_3_2=Ct2_3_2+delta;
   elseif dcheck=='U',
      Ct2_3_2=Ct2_3_2+2*delta;
   elseif dcheck=='d',
      Ct2_3_2=Ct2_3_2-delta;
   elseif dcheck=='D',
      Ct2_3_2=Ct2_3_2-3*delta;
   elseif dcheck=='b',
      Ct2_3_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(9);loglog(Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_3_2*((2*pi/Ustr_3).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'r');
end;

figure(10);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.0002;
   if dcheck=='u',
      Ct2_4_2=Ct2_4_2+delta;
   elseif dcheck=='U',
      Ct2_4_2=Ct2_4_2+2*delta;
   elseif dcheck=='d',
      Ct2_4_2=Ct2_4_2-delta;
   elseif dcheck=='D',
      Ct2_4_2=Ct2_4_2-3*delta;
   elseif dcheck=='b',
      Ct2_4_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(10);loglog(Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_4_2*((2*pi/Ustr_4).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'r');
end;

figure(11);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.0002;
   if dcheck=='u',
      Ct2_5_2=Ct2_5_2+delta;
   elseif dcheck=='U',
      Ct2_5_2=Ct2_5_2+2*delta;
   elseif dcheck=='d',
      Ct2_5_2=Ct2_5_2-delta;
   elseif dcheck=='D',
      Ct2_5_2=Ct2_5_2-3*delta;
   elseif dcheck=='b',
      Ct2_5_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(11);loglog(Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_5_2*((2*pi/Ustr_5).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'r');
end;

figure(12);hold
while 1
   dcheck=input('Up? Down? Okay?   ','s')
   delta=0.0002;
   if dcheck=='u',
      Ct2_6_2=Ct2_6_2+delta;
   elseif dcheck=='U',
      Ct2_6_2=Ct2_6_2+2*delta;
   elseif dcheck=='d',
      Ct2_6_2=Ct2_6_2-delta;
   elseif dcheck=='D',
      Ct2_6_2=Ct2_6_2-3*delta;
   elseif dcheck=='b',
      Ct2_6_2=9;
      break
   elseif dcheck=='o',
      break
   end;
   figure(12);loglog(Fson(fminT-10:fmaxT+7),Fson(fminT-10:fmaxT+7).*Ct2_6_2*((2*pi/Ustr_6).^(-2/3))./cS.*Fson(fminT-10:fmaxT+7).^(-5/3),'r');
end;

%figure(13);hold
%while 1
%   dcheck=input('Up? Down? Okay?   ','s')
%   delta=0.0002;
%   if dcheck=='u',
%      Cq2_1_2=Cq2_1_2+delta;
%   elseif dcheck=='U',
%      Cq2_1_2=Cq2_1_2+2*delta;
%   elseif dcheck=='d',
%      Cq2_1_2=Cq2_1_2-delta;
%   elseif dcheck=='D',
%      Cq2_1_2=Cq2_1_2-3*delta;
%   elseif dcheck=='b',
%      Cq2_1_2=9;
%      break
%   elseif dcheck=='o',
%      break
%   end;
%   figure(13);loglog(Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_1_2*((2*pi/Ustr_1).^(-2/3))./cS.*Fson(fminO-12:fmaxO+7).^(-5/3),'r');
%end;

%figure(14);hold
%while 1
%   dcheck=input('Up? Down? Okay?   ','s')
%   delta=0.0002;
%   if dcheck=='u',
%      Cq2_2_2=Cq2_2_2+delta;
%   elseif dcheck=='U',
%      Cq2_2_2=Cq2_2_2+2*delta;
%   elseif dcheck=='d',
%      Cq2_2_2=Cq2_2_2-delta;
%   elseif dcheck=='D',
%      Cq2_2_2=Cq2_2_2-3*delta;
%   elseif dcheck=='b',
%      Cq2_2_2=9;
%      break
%   elseif dcheck=='o',
%      break
%   end;
%   figure(14);loglog(Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_2_2*((2*pi/Ustr_2).^(-2/3))./cS.*Fson(fminO-12:fmaxO+7).^(-5/3),'r');
%end;

%figure(15);hold
%while 1
%   dcheck=input('Up? Down? Okay?   ','s')
%   delta=0.0002;
%   if dcheck=='u',
%      Cq2_3_2=Cq2_3_2+delta;
%   elseif dcheck=='U',
%      Cq2_3_2=Cq2_3_2+2*delta;
%   elseif dcheck=='d',
%      Cq2_3_2=Cq2_3_2-delta;
%   elseif dcheck=='D',
%      Cq2_3_2=Cq2_3_2-3*delta;
%   elseif dcheck=='b',
%      Cq2_3_2=9;
%      break
%   elseif dcheck=='o',
%      break
%   end;
%   figure(15);loglog(Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_3_2*((2*pi/Ustr_3).^(-2/3))./cS.*Fson(fminO-12:fmaxO+7).^(-5/3),'r');
%end;

%figure(16);hold
%while 1
%   dcheck=input('Up? Down? Okay?   ','s')
%   delta=0.0002;
%   if dcheck=='u',
%      Cq2_4_2=Cq2_4_2+delta;
%   elseif dcheck=='U',
%      Cq2_4_2=Cq2_4_2+2*delta;
%   elseif dcheck=='d',
%      Cq2_4_2=Cq2_4_2-delta;
%   elseif dcheck=='D',
%      Cq2_4_2=Cq2_4_2-3*delta;
%   elseif dcheck=='b',
%      Cq2_4_2=9;
%      break
%   elseif dcheck=='o',
%      break
%   end;
%   figure(16);loglog(Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_4_2*((2*pi/Ustr_4).^(-2/3))./cS.*Fson(fminO-12:fmaxO+7).^(-5/3),'r');
%end;

%figure(17);hold
%while 1
%   dcheck=input('Up? Down? Okay?   ','s')
%   delta=0.0002;
%   if dcheck=='u',
%      Cq2_5_2=Cq2_5_2+delta;
%   elseif dcheck=='U',
%      Cq2_5_2=Cq2_5_2+2*delta;
%   elseif dcheck=='d',
%      Cq2_5_2=Cq2_5_2-delta;
%   elseif dcheck=='D',
%      Cq2_5_2=Cq2_5_2-3*delta;
%   elseif dcheck=='b',
%      Cq2_5_2=9;
%      break
%   elseif dcheck=='o',
%      break
%   end;
%   figure(17);loglog(Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_5_2*((2*pi/Ustr_5).^(-2/3))./cS.*Fson(fminO-12:fmaxO+7).^(-5/3),'r');
%end;

%figure(18);hold
%while 1
%   dcheck=input('Up? Down? Okay?   ','s')
%   delta=0.0002;
%   if dcheck=='u',
%      Cq2_6_2=Cq2_6_2+delta;
%   elseif dcheck=='U',
%      Cq2_6_2=Cq2_6_2+2*delta;
%   elseif dcheck=='d',
%      Cq2_6_2=Cq2_6_2-delta;
%   elseif dcheck=='D',
%      Cq2_6_2=Cq2_6_2-3*delta;
%   elseif dcheck=='b',
%      Cq2_6_2=9;
%      break
%   elseif dcheck=='o',
%      break
%   end;
%   figure(18);loglog(Fson(fminO-12:fmaxO+7),Fson(fminO-12:fmaxO+7).*Cq2_6_2*((2*pi/Ustr_6).^(-2/3))./cS.*Fson(fminO-12:fmaxO+7).^(-5/3),'r');
%end;

y=yship_1;x=xship_1;Cu2=Cu2_1_2;Ct2=Ct2_1_2;Cq2=Cq2_1_2;Cc2=Cc2_1_2;Co2=Co2_1_2;Q=Qbar_1;idiss;usid_1_2=us0;tsid_1_2=ts_ib;qsid_1_2=qs_ib;osid_1_2=os_ib;csid_1_2=cs_ib;Lid_1_2=z_u/zet;
y=yship_2;x=xship_2;Cu2=Cu2_2_2;Ct2=Ct2_2_2;Cq2=Cq2_2_2;Cc2=Cc2_2_2;Co2=Co2_2_2;Q=Qbar_2;idiss;usid_2_2=us0;tsid_2_2=ts_ib;qsid_2_2=qs_ib;osid_2_2=os_ib;csid_2_2=cs_ib;Lid_2_2=z_u/zet;
y=yship_3;x=xship_3;Cu2=Cu2_3_2;Ct2=Ct2_3_2;Cq2=Cq2_3_2;Cc2=Cc2_3_2;Co2=Co2_3_2;Q=Qbar_3;idiss;usid_3_2=us0;tsid_3_2=ts_ib;qsid_3_2=qs_ib;osid_3_2=os_ib;csid_3_2=cs_ib;Lid_3_2=z_u/zet;
y=yship_4;x=xship_4;Cu2=Cu2_4_2;Ct2=Ct2_4_2;Cq2=Cq2_4_2;Cc2=Cc2_4_2;Co2=Co2_4_2;Q=Qbar_4;idiss;usid_4_2=us0;tsid_4_2=ts_ib;qsid_4_2=qs_ib;osid_4_2=os_ib;csid_4_2=cs_ib;Lid_4_2=z_u/zet;
y=yship_5;x=xship_5;Cu2=Cu2_5_2;Ct2=Ct2_5_2;Cq2=Cq2_5_2;Cc2=Cc2_5_2;Co2=Co2_5_2;Q=Qbar_5;idiss;usid_5_2=us0;tsid_5_2=ts_ib;qsid_5_2=qs_ib;osid_5_2=os_ib;csid_5_2=cs_ib;Lid_5_2=z_u/zet;
y=yship_6;x=xship_6;Cu2=Cu2_6_2;Ct2=Ct2_6_2;Cq2=Cq2_6_2;Cc2=Cc2_6_2;Co2=Co2_6_2;Q=Qbar_6;idiss;usid_6_2=us0;tsid_6_2=ts_ib;qsid_6_2=qs_ib;osid_6_2=os_ib;csid_6_2=cs_ib;Lid_6_2=z_u/zet;

Unew=[Cu2_1_2 Cu2_2_2 Cu2_3_2 Cu2_4_2 Cu2_5_2 Cu2_6_2];
Tnew=[Ct2_1_2 Ct2_2_2 Ct2_3_2 Ct2_4_2 Ct2_5_2 Ct2_6_2];
Qnew=[Cq2_1_2 Cq2_2_2 Cq2_3_2 Cq2_4_2 Cq2_5_2 Cq2_6_2];

if Cu2_1_2==9,usid_1_2=9;end;
if Cu2_2_2==9,usid_2_2=9;end;
if Cu2_3_2==9,usid_3_2=9;end;
if Cu2_4_2==9,usid_4_2=9;end;
if Cu2_5_2==9,usid_5_2=9;end;
if Cu2_6_2==9,usid_6_2=9;end;
if Ct2_1_2==9,tsid_1_2=9;end;
if Ct2_2_2==9,tsid_2_2=9;end;
if Ct2_3_2==9,tsid_3_2=9;end;
if Ct2_4_2==9,tsid_4_2=9;end;
if Ct2_5_2==9,tsid_5_2=9;end;
if Ct2_6_2==9,tsid_6_2=9;end;
if Cq2_1_2==9,qsid_1_2=9;end;
if Cq2_2_2==9,qsid_2_2=9;end;
if Cq2_3_2==9,qsid_3_2=9;end;
if Cq2_4_2==9,qsid_4_2=9;end;
if Cq2_5_2==9,qsid_5_2=9;end;
if Cq2_6_2==9,qsid_6_2=9;end;
   
unew=[usid_1_2 usid_2_2 usid_3_2 usid_4_2 usid_5_2 usid_6_2];
tnew=[tsid_1_2 tsid_2_2 tsid_3_2 tsid_4_2 tsid_5_2 tsid_6_2];
qnew=[qsid_1_2 qsid_2_2 qsid_3_2 qsid_4_2 qsid_5_2 qsid_6_2];

Uold
Unew
Told
Tnew
Qold
Qnew
uold
unew
told
tnew
qold
qnew

new=[usid_1_2 tsid_1_2 qsid_1_2 Cu2_1_2 Ct2_1_2 Cq2_1_2
   usid_2_2 tsid_2_2 qsid_2_2 Cu2_2_2 Ct2_2_2 Cq2_2_2
   usid_3_2 tsid_3_2 qsid_3_2 Cu2_3_2 Ct2_3_2 Cq2_3_2
   usid_4_2 tsid_4_2 qsid_4_2 Cu2_4_2 Ct2_4_2 Cq2_4_2
   usid_5_2 tsid_5_2 qsid_5_2 Cu2_5_2 Ct2_5_2 Cq2_5_2
   usid_6_2 tsid_6_2 qsid_6_2 Cu2_6_2 Ct2_6_2 Cq2_6_2];

sfl=['save d:\temp\day',ddd,'\u_',ddd,hhh,'.prn new -ascii'];
disp(sfl)
eval(sfl)
