%Chapter 2, Fig. 2.6 (a) %Eric Dubois, updated 2018-11-08 %Shading plot of Gaussian function %the image is square 1ph x 1ph sampled at 201 x 201 % 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)/200; x=L1:del:L2; y=x; %x and y values between 0 and +1 spaced by 0.01 r = 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*r^2)); % generate the Gaussian function on the grid %create the plot figure image([L1,L2],[L1,L2],Z,'CDataMapping','scaled'); colormap(gray) xlabel('\itx \rm(ph)'), ylabel('\ity \rm(ph)'); 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',[0.5,0.5,15,15]); set(gcf,'Color',[1 1 1]);