Matlab 作图
1,平面作图
x = 0:pi/100:2*pi;
plot(x,sin(x), x, cos(x), x,sin(2*x))
x = 0:pi/.01:2*pi;plot(cos(x),sin(x)); axis equal; % draw a circle
2,三维作图
墨西哥草帽
[X, Y ] = meshgrid(-8:.5:8);
r = sqrt(X.^2 + Y.^2) + eps;
Z = sin(r)./r;
mesh(X,Y,Z)
surf(X,Y,Z)
3, 符号作图
ezplot('sin(x)-x')
ezplot('sin(x)+cos(x)')
ezplot('(x.^3 - x.^2 - x +1).^(1/3)',[-1 2])
ezplot('sqrt(1-x.^2)') % 半圆
ezmesh('(1-x.^2-y.^2).^(1/2)') % semisphere
ezmesh('x.^2+2.*(y.^2)') % parabola
4, 常用图型
% 圆柱
t=ones(1,40)*5;
[x,y,z]=cylinder(t);
c=ones(size(z));
surf(x,y,z,c)
shading faceted
title('圆柱')
axis off
% 椭球
t=linspace(0,pi,100);
[x,y,z]=cylinder(sin(t)/4);
c=ones(size(z));
mesh(x,y,z,c)
shading faceted
title('椭球')
axis equal
axis off
% 椭球2
t=linspace(0,pi,100);
[x,y,z]=cylinder(cos(t));
c=ones(size(z));
mesh(x,y,z,c)
shading faceted
title('椭球')
axis equal
axis off
1,平面作图
x = 0:pi/100:2*pi;
plot(x,sin(x), x, cos(x), x,sin(2*x))
x = 0:pi/.01:2*pi;plot(cos(x),sin(x)); axis equal; % draw a circle
2,三维作图
墨西哥草帽
[X, Y ] = meshgrid(-8:.5:8);
r = sqrt(X.^2 + Y.^2) + eps;
Z = sin(r)./r;
mesh(X,Y,Z)
surf(X,Y,Z)
3, 符号作图
ezplot('sin(x)-x')
ezplot('sin(x)+cos(x)')
ezplot('(x.^3 - x.^2 - x +1).^(1/3)',[-1 2])
ezplot('sqrt(1-x.^2)') % 半圆
ezmesh('(1-x.^2-y.^2).^(1/2)') % semisphere
ezmesh('x.^2+2.*(y.^2)') % parabola
4, 常用图型
% 圆柱
t=ones(1,40)*5;
[x,y,z]=cylinder(t);
c=ones(size(z));
surf(x,y,z,c)
shading faceted
title('圆柱')
axis off
% 椭球
t=linspace(0,pi,100);
[x,y,z]=cylinder(sin(t)/4);
c=ones(size(z));
mesh(x,y,z,c)
shading faceted
title('椭球')
axis equal
axis off
% 椭球2
t=linspace(0,pi,100);
[x,y,z]=cylinder(cos(t));
c=ones(size(z));
mesh(x,y,z,c)
shading faceted
title('椭球')
axis equal
axis off