%Chapter 2, Fig. 2.6 (b)
%Eric Dubois, updated 2018-11-08
%Contour plot of Gaussian function
%the image is square 1ph x 1ph sampled at 1001 x 1001
% the parameter of the Gaussian is r = 0.2 ph
clear all, close all
%generate the Gaussian image
L1=0; L2=1;
del = (L2-L1)/1000;
x=L1:del:L2; y=x;        %x and y values between 0 and +1 spaced by del
r0 = 0.2;     
[X,Y]=meshgrid(x,y);   % generate a 2D grid of xy values
Z=exp(-((X-0.5).^2+(Y-0.5).^2)/(2*r0^2));    % generate the Gaussian function on the grid
figure
[C,h]=contour(X,Y,Z); % generate the contour plot, including values to label contours
axis square;
lev1 = 0:.1:1.; % contours will be from 0 to 1 in steps of 0.1
clabel(C,h,lev1,'FontSize',6);    %label the contours            
xlabel('\itx \rm(ph)'), ylabel('\ity \rm(ph)');
colormap([0 0 0]);     % use black only
set(gca,'ydir','reverse'); 
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',[0.5,0.5,15,15]);
set(gcf,'Color',[1 1 1]);