E=getresult("Phase","E");
Ex=pinch(E.Ex); Ey=pinch(E.Ey);
phi_LCP = angle(Ex+1i*Ey);
phi_RCP = angle(Ex-1i*Ey);

phi_LCP=unwrap(phi_LCP);
phi_LCP=phi_LCP/pi*180; #unit of angle is degree
f=E.f; 
lambda=E.lambda;

matlabsave("phi_LCP_f_L_620_W_150",f,phi_LCP);


Ex=getdata("Transmission","Ex");
Ey=getdata("Transmission","Ey");
E = getelectric("Transmission");
x=getdata("Transmission","x");
y=getdata("Transmission","y");
    
E_LCP = Ex+1i*Ey;
E_RCP = Ex-1i*Ey;

P_RCP = (abs(E_RCP))^2;
P_LCP = (abs(E_LCP))^2;
T=transmission("Transmission");
    
RCP_T = 0.5*integrate(P_RCP,1:2,x,y)/integrate(E,1:2,x,y)*T;#Tansmission of RCP
LCP_T = 0.5*integrate(P_LCP,1:2,x,y)/integrate(E,1:2,x,y)*T;#Tansmission of LCP

matlabsave("LCP_T_f_L_620_W_150", f, LCP_T);
