%!Freq         MagS11       AngS11       MagS21       AngS21       MagS12       AngS12       MagS22       AngS22

%BF199_Phi_10V_7mA_theor

SP = zeros(32,9);

SP(1,:) = [25           0.72121      -60.723      15.961       144.13       0.0049494    56.573       0.95667      -3.7523]      ;
SP(2,:) =[50           0.64373      -98.466      11.355       123.57       0.0070495    38.515       0.91567      -4.2363]      ;
SP(3,:) =[75           0.60453      -119.95      8.4102       112.37       0.0078452    29.794       0.89612      -3.9358]      ;
SP(4,:) =[100          0.58517      -133.01      6.5839       105.44       0.0082082    25.334       0.88683      -3.6819 ]     ;
SP(5,:) =[125          0.57473      -141.6       5.3803       100.61       0.0084098    22.974       0.88199      -3.5569  ]    ;
SP(6,:) =[150          0.56858      -147.61      4.538        96.954       0.0085429    21.765       0.87924      -3.5341   ]   ;
SP(7,:) =[175          0.56469      -152.03      3.919        93.993       0.0086442    21.242       0.8776       -3.5838    ]  ;
SP(8,:) =[200          0.56209      -155.4       3.4465       91.482       0.0087306    21.156       0.8766       -3.6849]      ;
SP(9,:) =[225          0.56026      -158.07      3.0747       89.279       0.0088104    21.361       0.87599      -3.823  ]     ;
SP(10,:) =[250          0.55893      -160.21      2.7748       87.295       0.0088881    21.766       0.87564      -3.9884  ]    ;
SP(11,:) =[275          0.55793      -161.98      2.528        85.47        0.0089662    22.313       0.87548      -4.1744   ]   ;
SP(12,:) =[300          0.55717      -163.46      2.3214       83.767       0.0090463    22.96        0.87545      -4.3765    ]  ;
SP(13,:) =[325          0.55656      -164.72      2.1461       82.157       0.0091293    23.678       0.87552      -4.5912     ] ;
SP(14,:) =[350          0.55607      -165.81      1.9954       80.622       0.0092157    24.449       0.87568      -4.8162      ];
SP(15,:) =[375          0.55567      -166.75      1.8646       79.146       0.0093059    25.255       0.8759       -5.0494      ];
SP(16,:) =[400          0.55534      -167.57      1.75         77.72        0.0094001    26.085       0.87618      -5.2896      ];
SP(17,:) =[425          0.55506      -168.3       1.6488       76.333       0.0094985    26.93        0.87652      -5.5357      ];
SP(18,:) =[450          0.55482      -168.95      1.5588       74.981       0.009601     27.783       0.8769       -5.7868      ];
SP(19,:) =[475          0.55462      -169.53      1.4782       73.657       0.0097077    28.638       0.87733      -6.0422      ];
SP(20,:) =[500          0.55444      -170.06      1.4056       72.358       0.0098186    29.491       0.87779      -6.3015      ];
SP(21,:) =[525          0.55428      -170.53      1.3399       71.08        0.0099335    30.338       0.87829      -6.5641      ];
SP(22,:) =[550          0.55413      -170.96      1.2802       69.821       0.010052     31.177       0.87882      -6.8297      ];
SP(23,:) =[575          0.554        -171.36      1.2257       68.577       0.010175     32.004       0.87939      -7.0981      ];
SP(24,:) =[600          0.55388      -171.72      1.1758       67.349       0.010302     32.817       0.87999      -7.369       ];
SP(25,:) =[625          0.55378      -172.06      1.1298       66.132       0.010432     33.617       0.88062      -7.6422      ];
SP(26,:) =[650          0.55367      -172.36      1.0874       64.928       0.010566     34.4         0.88128      -7.9176      ];
SP(27,:) =[675          0.55358      -172.65      1.0482       63.733       0.010704     35.167       0.88197      -8.1949      ];
SP(28,:) =[700          0.55349      -172.91      1.0117       62.548       0.010845     35.917       0.88269      -8.4742      ];
SP(29,:) =[725          0.55341      -173.16      0.97781      61.371       0.010989     36.648       0.88344      -8.7552      ];
SP(30,:) =[750          0.55333      -173.39      0.94618      60.202       0.011137     37.361       0.88421      -9.038       ];
SP(31,:) =[775          0.55325      -173.61      0.91659      59.04        0.011288     38.056       0.88501      -9.3224      ];
SP(32,:) =[800          0.55318      -173.81      0.88886      57.885       0.011441     38.732       0.88583      -9.6085      ];

S11_DF4AE = zeros(32,1);
S11_DF4AE_ANGLE = zeros(32,1);
S21_DF4AE = zeros(32,1);
S21_DF4AE_ANGLE = zeros(32,1);
S12_DF4AE = zeros(32,1);
S12_DF4AE_ANGLE = zeros(32,1);
S22_DF4AE = zeros(32,1);
S22_DF4AE_ANGLE = zeros(32,1);

Freq1 = SP(:,1)*1e6;
S11_DF4AE = SP(:,2);
S11_DF4AE_ANGLE = SP(:,3);
S21_DF4AE = SP(:,4);
S21_DF4AE_ANGLE = SP(:,5);
S12_DF4AE = SP(:,6);
S12_DF4AE_ANGLE = SP(:,7);
S22_DF4AE = SP(:,8);
S22_DF4AE_ANGLE = SP(:,9);

SP_CDIL = zeros(6,9);
SP_CDIL(1,:) = [0.025  0.0000    0.0  13.410  163.0  0.0067   00.0  0.0000    0.0];
SP_CDIL(2,:) = [ 0.050  0.7260  -40.7  11.480  144.0  0.0058   77.0  0.8750   -5.8];
SP_CDIL(3,:) = [ 0.100  0.5120  -67.6   8.660  117.0  0.0108   72.3  0.8250   -3.6];
SP_CDIL(4,:) = [ 0.200  0.3520 -121.6   4.900   98.9  0.0166   85.4  0.8410  -10.9];
SP_CDIL(5,:) = [ 0.400  0.0000   00.0   0.000   00.0  0.0000   00.0  0.0000    0.0];
SP_CDIL(6,:) = [ 0.800  0.0000   00.0   0.000   00.0  0.0000   00.0  0.0000    0.0];

freq = SP_CDIL(:,1)*1e9;
S11_CDIL = SP_CDIL(:,2);
S11_CDIL_ANGLE = SP_CDIL(:,3);
S21_CDIL = SP_CDIL(:,4);
S21_CDIL_ANGLE = SP_CDIL(:,5);
S12_CDIL = SP_CDIL(:,6);
S12_CDIL_ANGLE = SP_CDIL(:,7);
S22_CDIL = SP_CDIL(:,8);
S22_CDIL_ANGLE = SP_CDIL(:,9);

close all
figure(1)
subplot(2,1,1)
semilogx(frequency,abs(S11),Freq1,S11_DF4AE,'bo',freq,S11_CDIL,'ro')
title('|S_{11}|')
subplot(2,1,2)
semilogx(frequency,angle(S11)*180/pi,Freq1,S11_DF4AE_ANGLE,'bo',freq,S11_CDIL_ANGLE,'ro')
xlabel('frequency (Hz)')
ylabel('Degrees')
title('angle S_{11}')

figure(2)
subplot(2,1,1)
semilogx(frequency,abs(S21),Freq1,S21_DF4AE,'bo',freq,S21_CDIL,'ro')
title('|S_{21}|')
subplot(2,1,2)
semilogx(frequency,angle(S21)*180/pi,Freq1,S21_DF4AE_ANGLE,'bo',freq,S21_CDIL_ANGLE,'ro')
xlabel('frequency (Hz)')
ylabel('Degrees')
title('angle S_{21}')

figure(3)
subplot(2,1,1)
semilogx(frequency,abs(S12),Freq1,S12_DF4AE,'bo',freq,S12_CDIL,'ro')
title('|S_{12}|')
subplot(2,1,2)
semilogx(frequency,angle(S12)*180/pi,Freq1,S12_DF4AE_ANGLE,'bo',freq,S12_CDIL_ANGLE,'ro')
xlabel('frequency (Hz)')
ylabel('Degrees')
title('angle S_{12}')

figure(4)
subplot(2,1,1)
semilogx(frequency,abs(S22),Freq1,S22_DF4AE,'bo',freq,S22_CDIL,'ro')
title('|S_{22}|')
subplot(2,1,2)
semilogx(frequency,angle(S22)*180/pi,Freq1,S22_DF4AE_ANGLE,'bo',freq,S22_CDIL_ANGLE,'ro')
xlabel('frequency (Hz)')
ylabel('Degrees')
title('angle S_{22}')
