#run the sweep runsweep("polarization_width_sweep"); # get the sweep results, transmission and gradting width. As T is a dataset, dot operator is used as well T_sweep = getsweepresult("polarization_width_sweep","T"); grating_width = getsweepdata("polarization_width_sweep","grating_width"); T = T_sweep.T; f = T_sweep.f; #T is a matrix of size 3x10x2. Extract p polarization transmission data and s polarization transmission data P = pinch(T,3,1); S = pinch(T,3,2); #Calculate the Contrast ratio C = transpose(P/S); # Plot the contrast ratio plot(2*grating_width*1e9,C,"pitch (nm)","Contrast Ratio (logplot)","","logplot"); legend(num2str(c/f(1)*1e9)+"nm",num2str(c/f(2)*1e9)+"nm",num2str(c/f(3)*1e9)+"nm");