close all;
[x,y] = meshgrid(linspace(-4,4,251));
r = sqrt(x.*x+y.*y);
z = cyl(x/3,y/3);
mysurf(x,y,z);
imshow(z);
close all;
[x,y] = meshgrid(linspace(-4,4,251));
r = sqrt(x.*x+y.*y);
z = somb(r);
mysurf(x,y,z);
r = linspace(-4,4,251); z = somb(r); plot(r,z);
close all;
[x,y] = meshgrid(linspace(-4,4,251));
r = sqrt(x.*x+y.*y);
z = gaus((r-2)/0.2);
mysurf(x,y,z);
imshow(z);
We use gaus to simulate delta function
x = linspace(-2,2,401); y = gaus(sin(pi*x)/0.2); plot(x,y,'k','LineWidth',2); axis([-2 2 0 1.5]);
[x,y] = meshgrid(linspace(-4,4,251)); z = rect(x/3).*rect(y/2); imshow(z);
z = cyl(x/3,y/2); imshow(z);
close all;
[x,y] = meshgrid(linspace(-4,4,251));
z = tri(x/2).*tri(y/2);
mysurf(x,y,z);
imshow(z);
close all;
[x,y] = meshgrid(linspace(-4,4,251));
r = sqrt(x.*x+y.*y);
z = tri(r/2);
mysurf(x,y,z);
imshow(z);
% triangle
[x y] = meshgrid(linspace(-4,4,251));
z = polygon(x,y);
imshow(z);
% hexagon
theta = (pi/3)*(0:5);
p = [cos(theta') sin(theta')];
z = polygon(x,y,3*p);
imshow(z);
文中所用的程序可在 http://www.johnloomis.org/eop513/notes/ 下载