closeall; clear; E = getresult('field','E'); Ex = E.Ex; Ez = E.Ez; y = E.y; # track the TE fraction in side the rotator TE_frac = matrix(length(y)); for (i=1:length(y)){ Ex_slice = pinch(Ex,2,i); Ez_slice = pinch(Ez,2,i); TE_frac(i) = abs(Ex_slice)^2/(abs(Ex_slice)^2+abs(Ez_slice)^2); } plot(y*1e6,TE_frac,'y (um)','TE Fraction'); # find the distance (d) corresponding to angle of rotation (beta) = 45 degrees ind = find(TE_frac,0.5); # 45 degrees correspond to TE fraction of 0.5 ?d = y(ind)-y(1); # distance