GTRUNC Diffraction patterns of Truncated Gaussians
by Chuck DiMarzio Northeastern University 2010
!! This file may be copied, used, or modified for educational and !! research purposes provided that this header information is not !! removed or altered, and provided that the book is cited in !! publications, as DiMarzio, Charles A., Optics for Engineers, !! CRC Press, Boca Raton, FL, 2011. !! http://www.crcpress.com !! Other distribution is prohibited without permission.
Contents
Start
xaxis=fftaxisshift((0:1023)*16/1024); subregion=(floor(length(xaxis)/4):floor(length(xaxis)*3/4)); [x,y]=meshgrid(xaxis,xaxis); % Gaussian through circular aperture r=sqrt(x.^2+y.^2); test=find(r<1/2); h=(0.3:0.01:2); for nh=1:length(h); pup=zeros(size(x)); w=h(nh)/2; pup(test)=sqrt(2/(pi*w^2))*exp(-r(test).^2/w^2); test1=find(abs(xaxis)<0.8); pslices(nh,1:length(test1))=real(pup(floor(length(xaxis)/2),test1)); img=fftshift(fft2(fftshift(pup))); faxis=fftaxisshift(fftaxis(xaxis)); test2=find(abs(faxis)<4); slices(nh,1:length(test2))=real(img(floor(length(faxis)/2),test2)); %close all; end; fcount=14; fig15=figure;imagesc(xaxis(test1),h,(abs(pslices))); colormap(flipud(gray));colorbar; xlabel('x, Location'); ylabel('h, Fill Factor'); fcount=fcount+1; %print('-depsc',[epspath,'8-',num2strz(fcount,2),'-gtrunc.eps']); fig16=figure;imagesc(faxis(test2),h,20*log10(abs(slices))); moose=caxis;caxis(ceil(max(moose))+[-40,0]);colormap(flipud(gray));colorbar; xlabel('f_x, Spatial Frequency'); ylabel('h, Fill Factor'); fcount=fcount+1; %print('-depsc',[epspath,'8-',num2strz(fcount,2),'-gtrunc.eps']); fig16a=figure;plot(pslices'); fig17=figure;mesh(xaxis(test1),h,pslices); colormap([[0.5,0.5,0.5];colormap]); hold on;plot3(-[0.5,0.5],[0.3,2],0.02+[0,0],'k'); hold on;plot3([0.5,0.5],[0.3,2],0.02+[0,0],'k'); xlabel('x, Location'); ylabel('h, Fill Factor'); zlabel('Field'); view(-151,28); fcount=fcount+1; %print('-depsc',[epspath,'8-',num2strz(fcount,2),'-gtrunc.eps']); fig18=figure;mesh(faxis(test2),h,slices); xlabel('f_x, Spatial Frequency'); ylabel('h, Fill Factor'); zlabel('Field'); view(-151,28); red=gray; red(:,1)=1; blue=gray; blue(:,3)=1; %rbmap=[blue(1:2:end,:);flipud(red)]; rbmap=[blue(1:4:end-16,:);flipud(red(1:end-16,:))]; caxis(1500*[-1/4,1]); colormap(rbmap);colorbar; fcount=fcount+1; %print('-depsc',[epspath,'8-',num2strz(fcount,2),'-gtrunc.eps']); fig19=figure;plot(h,slices(:,64),'k'); xlabel('h, Fill Factor'); ylabel('Axial Irradiance'); imax=max(slices(:,64)); hmax=h(find(slices(:,64)==max(slices(:,64)))); legend([' max = ',num2str(imax),' at h = '... ,num2str(hmax)],'Location','SouthEast'); fcount=fcount+1; %print('-depsc',[epspath,'8-',num2strz(fcount,2),'-gtrunc.eps']); fxstep=faxis(2)-faxis(1); aslices=abs(slices(:,64:end)); for q=1:length(h); tt=find((aslices(q,1:end-2)>aslices(q,2:end-1))&... (aslices(q,2:end-1)<aslices(q,3:end))); if(length(tt)>0);th=tt(1);else th=0;end; xnull1(q)=(th-1)*fxstep; if(length(tt)>1);th=tt(2);else th=0;end; xnull2(q)=(th-1)*fxstep; if(length(tt)>2);th=tt(3);else th=0;end; xnull3(q)=(th-1)*fxstep; end; test1n=find(xnull1>0);test2n=find(xnull2>0);test3n=find(xnull3>0); fig20=figure;plot(h(test1n),xnull1(test1n),'k-',... h(test2n),xnull2(test2n),'k.',... h(test3n),xnull3(test3n),'k-.'); xlabel('h, Fill Factor'); ylabel('Null Locations'); fcount=fcount+1; %print('-depsc',[epspath,'8-',num2strz(fcount,2),'-gtrunc.eps']);






