%Chapter 2, Fig. 2.5 
%Eric Dubois, updated 2018-11-07
%Zone plate with axes
%zone plate parameter is r_0^2 = (1/250) ph which can be modified by changing
%r2.
%The zone plate may appear aliased if not displayed at sufficiently high
%size/resolution

close all, clear all
%Zone plate is a square image of size 1ph x 1ph, sampled as 1201x1201 
L1=-0.5; L2=0.5;
dx=1/1200;                     %sample spacing
x=L1:dx:L2; y=x;          %x and y values between -0.5 and +0.5 spaced by dx
[X,Y]=meshgrid(x,y);         % generate a 2D grid of xy values
r2=1/250;
Z=(1 + cos(pi*(X.^2+Y.^2)./r2))./2;   % generate the zone plate
                                      %function on the grid
[r,c]=size(Z);
%create the plot
figure                                      
image([L1 L2],[L1 L2],Z,'CDataMapping','scaled')
colormap(gray)
set(gca,'dataaspectratio',[1 1 1]);  %make the plot square
set(gca,'ydir','reverse');           %vertical axis points down
set(gca,'XAxisLocation','top');      %Xaxis labels on top
set(gca,'FontName','times')          %set the plot font to times
set(gca,'FontSize',8)                %set the plot size to 8pt
set(gcf,'units','centimeters','position',[.5,.5,10.16,10.16]);
set(gcf,'Color',[1 1 1]);
xlabel('\itx \rm(ph)'), ylabel('\ity \rm(ph)');
