plot, surf, mesh

plot 正弦曲线

x = 0:pi/100:2*pi; % 步长pi/100,将2pi分成200份
y = sin(x);
plot(x,y);
plot, surf, mesh_第1张图片
正弦曲线

surf 曲线

a = -1:.1:1;
[x,y] = meshgrid(a);
z = x.^2 + y.^2;
surf(x,y,z);
plot, surf, mesh_第2张图片
曲面图

球体

[x,y,z]=sphere(50); % 指定球由半圆弧由50个网格组成
mesh(3*x,3*y,3*z); % 指定球的半径为3
plot, surf, mesh_第3张图片
球体
>> [x,y,z]=sphere(4) //4个网格,5个点,类似正弦曲线的五点法作图

x =

                   0                   0                   0                   0                   0
  -0.707106781186548   0.000000000000000   0.707106781186548   0.000000000000000  -0.707106781186548
  -1.000000000000000   0.000000000000000   1.000000000000000   0.000000000000000  -1.000000000000000
  -0.707106781186548   0.000000000000000   0.707106781186548   0.000000000000000  -0.707106781186548
                   0                   0                   0                   0                   0


y =

                   0                   0                   0                   0                   0
                   0  -0.707106781186548                   0   0.707106781186548                   0
                   0  -1.000000000000000                   0   1.000000000000000                   0
                   0  -0.707106781186548                   0   0.707106781186548                   0
                   0                   0                   0                   0                   0


z =

  -1.000000000000000  -1.000000000000000  -1.000000000000000  -1.000000000000000  -1.000000000000000
  -0.707106781186547  -0.707106781186547  -0.707106781186547  -0.707106781186547  -0.707106781186547
                   0                   0                   0                   0                   0
   0.707106781186547   0.707106781186547   0.707106781186547   0.707106781186547   0.707106781186547
   1.000000000000000   1.000000000000000   1.000000000000000   1.000000000000000   1.000000000000000

总共选取了14个点,效果差很多。

plot, surf, mesh_第4张图片
14点球

你可能感兴趣的:(plot, surf, mesh)