No BSD License  

Highlights from
Numerical Analysis and Graphic Visualization with MATLAB

l2_19.m
% L2_19 : Figure 2.14 
% Lllustrates contour plots with manual labeling.
% Follow instruction on the command screen.  Plots Figure 2.14.
% Copyright S. Nakamura, 1995
set(gcf, 'NumberTitle','off','Name', 'Figure 2.14; List 2.19')

clear, clf, clc, axis('square')
xm=-2:.2:2; ym=-2:.2:2;
[x , y ] = meshgrid(xm,ym);
z = x .* exp(-x.^2 - y.^2);
zmax=max(max(z)); zmin=min(min(z));
dz = (zmax-zmin)/10;
level = zmin + 0.5*dz: dz: zmax;
k=input('If you wish to put contour label manually, type 1; if not 0.');
if k==1
disp 'The following messages are generated by clabel command'
disp '(use mouse in the figure window):'
h=contour(x,y,z,level); clabel(h,'manual')
title('Contour plot by contour(x,y,z,level)')
xlabel('x'); ylabel('y')
end
if k==0
h=contour(x,y,z,level); clabel(h)
title('Contour plot by contour(x,y,z,level)')
xlabel('x'); ylabel('y')
end

Contact us at files@mathworks.com