1,三维曲线
**plot3(x,y,z)通过描点连线画出曲图,**这里x,y,z都是n维向量,分别表示该曲线上点集的横坐标,纵坐标,竖坐标。
t=0:pi/50:10*pi;
subplot(121),plot3(sin(t),cos(t),t);
subplot(122),fplot3(@(t)sin(t),@(t)cos(t),@(t)t,[0,10*pi])

2,网格图
**命令mesh(x,y,z)画网格曲图。**这里x,y,z是三个同维数的数据矩阵,分别表示数据点的横坐标,纵坐标,竖坐标,命令mesh(x,y,z)将该数据点在空间中描出u,并且连成网格
示例:绘制二元函数z=sin(xy)/xy
clc,clear,close all
x=-5:0.2:5;
[x,y]=meshgrid(x);%生成网格数据
z=(sin(x./y)+eps)./(x.*y+eps);%为避免0/0,分子分母都加eps,变成浮点精度型
subplot(121),mesh(x,y,z)
subplot(122),fmesh(@(x,y)sin(x.*y)./(x.*y))

3,表面图
**命令surf(x,y,z)画三维,**这里x,y,z是三个同维数的数据矩阵,分别表示数据点的横坐标,纵坐标,竖坐标
示例:绘制二元函数z=sin(xy)/xy
clc,clear,close all
x=-5:0.2:5;
[x,y]=meshgrid(x);
z=(sin(x./y)+eps)./(x.*y+eps);%为避免0/0,分子分母都加eps,变成浮点精度型
subplot(121),surf(x,y,z)
subplot(122),fsurf(@(x,y)sin(x.*y)./(x.*y))

4,旋转曲图
示例:

使用命令fmesh画图,matlab程序如下:
clc,clear,close all
f=@(x,y,z)x.^2+(sqrt(y.^2+z.^2)-5).^2-16;
subplot(121),fimplicit3(f,[-4,4,-9,9,-9,9])
x=@(u,v)4*cos(u);
y=@(u,v)(5+4*sin(u)).*cos(v);
z=@(u,v)(5+4*sin(u)).*sin(v);
subplot(122),fsurf(x,y,z)

5,二次曲面图形
matlab中使用绘图命令fmesh或fsurf,画显函数或参数方程表示的二次曲面很方便
或者直接用fimlicit3画隐函数表示的二次曲面
5.1 单页双曲面
示例:

clc,clear,close all
f=@(x,y,z)x.^2/4+y.^2/10-z.^2/8-1;
subplot(121),fimplicit3(f,[-20,20,-20,20,-15,15])
x=@(u,v)2*cosh(v).*cos(u);
y=@(u,v)sqrt(10)*cosh(v).*sin(u);
z=@(u,v)2*sqrt(2)*sin(v);
subplot(122),fmesh(x,y,z,[0,2*pi,-pi,pi]);

5.2 双叶双曲面
示例:
clc,clear,close all
f=@(x,y,z)x.^2/9-y.^2/4-z.^2-1;
fimplicit3(f)

5.3 抛物柱面
示例:y^2=x
clc,clear,close all
fsurf(@(y,z)y.^2)

5.4 椭圆锥面
示例:
clc,clear,close all
subplot(121)
fimplicit3(@(x,y,z)x.^2/9+y.^2/4-z.^2,[-6,6,-4,4,-2,2])
subplot(122),x=@(s,t)3*tan(s).*cos(t);
y=@(s,t)2*tan(s).*sin(t);
z=@(s,t)tan(s);
fsurf(x,y,z,[-1,1,0,2*pi])

5.5 椭圆球

clc,clear,close all
subplot(121),fimplicit3(@(x,y,z)x.^2/9+y.^2/9+z.^2/6-1)
subplot(122),ellipsoid(0,0,0,3,2,sqrt(6))

5.6 马鞍面
示例:z=xy
clc,clear,close all
fsurf(@(x,y)x.*y)

5.7 椭圆柱面

clc,clear,close all
subplot(121),fimplicit3(@(x,y,z)x.^2/9+y.^2/4-1)
x=@(u,v)3*cos(u);
y=@(u,v)2*sin(u);
z=@(u,v)v;
subplot(122),fsurf(x,y,z)

6,其他曲面图形

clc,clear,close all
r=@(s,t)2+sin(7*s+5*t);
x=@(s,t)r(s,t).*cos(s).*sin(t);
y=@(s,t)r(s,t).*sin(s).*cos(t);
z=@(s,t)r(s,t).*cos(t);
fmesh(x,y,z,[0,2*pi,0,pi]),alpha(0.8)


clc,clear,close all
fmesh(@(x,y) erf(x)+cos (y),[-5,0,-5,5]), hold on
fmesh (@ (x,y)sin(x)+cos(y),[0,5,-5, 5]), hold off

7,四维数据曲面图

