clear all; close all; N = 201; %generate a 201 by 201 array of points x=0:(1/(N-1)):1; y=x; % x and y values between 0 and +1 spaced by % 0.005 (201 values) r = 0.2; %set the r parameter [X,Y]=meshgrid(x,y); % generate 2D grids of xy values (201 by 201 arrays) X(i,j) = x(j) and Y(i,j) = y(i) Z=exp(-((X-0.5).^2+(Y-0.5).^2)/(2*r^2)); % generate the Gaussian function on the grid v=0:.1:1.; % contours will be from 0 to 1 in steps of 0.1 [C,h]=contour(X,Y,Z,v); % generate the contour plot, including values to label contours axis square %make the plot square clabel(C,h) %label the contours xlabel('x (ph)'), ylabel('y (ph)'); set(gca,'ydir','reverse'); set(gca,'XAxisLocation','top'); %Xaxis labels on top colormap([0 0 0]); % use black only figure, imshow(Z)