clear
n=1.50+0.005i;
x=400.0e0;
num=100;
Teta=linspace(0,pi,2*num-1);
[S1,S2,Qext,Qsca,Qback,g]=mie(x,n,num);
S11=0.5*((abs(S2)).^2+(abs(S1)).^2);
S12=0.5*((abs(S2)).^2-(abs(S1)).^2);
S33=0.5*(conj(S2).*S1+S2.*conj(S1));
S34=i/2*(conj(S2).*S1-S2.*conj(S1));

% Phase matrix
% 1. spherical particles S11=S22 and S33=S44
% 2. Rayleigh scattering S12=0
% only non zero components
P11=S11./(pi*x.^2*Qsca);
P12=S12./(pi*x.^2*Qsca);
P33=S33./(pi*x.^2*Qsca);
P34=S34./(pi*x.^2*Qsca);

% Normalization 
2*pi*trapz(Teta,P11.*sin(Teta))

%plot(Teta*180/pi,P11)
%grid
plot(Teta*180/pi,-(P12)./P11)
 