2.6 三维图形绘制&2.7 四维图形绘制

 

 

 

>> t=0:0.1:2*pi;
x=t.^3.*exp(-t).*sin(3*t);
y=t.^3.*exp(-t).*cos(3*t);z=t.^2;
plot3(x,y,z),grid
>> stem3(x,y,z)
>> plot3(x,y,z),grid
>> plot3(x,y,z),grid




>> [x,y]=meshgrid(-3:0.1:2,-2:0.1:2);
>>z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y);
>>subplot(2,2,1),mesh(x,y,z);
>>subplot(2,2,2),surf(x,y,z);
>>subplot(2,2,3),waterfall(x,y,z);
>>subplot(2,2,4),contour3(x,y,z,40);%瀑布,等高线,40是等高线条数

 

 

2.6 三维图形绘制&2.7 四维图形绘制

 

 

2.6 三维图形绘制&2.7 四维图形绘制

 

 

 

 

2.6 三维图形绘制&2.7 四维图形绘制

 

2.6 三维图形绘制&2.7 四维图形绘制

 

>> [x,y]=meshgrid(-1:0.04:1,-2:0.04:2);
z=0.5457*exp(-0.75*y.^2-3.75*x.^2-1.5*x).*(x+y>1)+0.7575*exp(-y.^2-6*x.^2).*((x+y>-1)&(x+y<=1))+0.5457*exp(-0.75*y.^2-3.75*x.^2-1.5*x).*(x+y<=1);
>> h=surf(x,y,z),shading flat

2.6 三维图形绘制&2.7 四维图形绘制

>> [x,y]=meshgrid(-3:0.1:2,-2:0.1:2);
z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y);
subplot(2,2,1),surf(x,y,z),view(0,90);%俯视图
subplot(2,2,2),surf(x,y,z),view(90,0);%侧视图
subplot(2,2,3),surf(x,y,z),view(0,0);%正视图
subplot(2,2,4),surf(x,y,z);%原图




>> syms u v;x=cos(u)+v*cos(u)*cos(u/2);
y=sin(u)+v*sin(u)*cos(u/2);
z=v*sin(u/2);
ezsurf(x,y,z,[0,2*pi,-0.5,0.5])



>> subplot(2,2,1),ezsurf(x,y,z,[0,2*pi,-0.5,0.5]),view(0,90);%俯视图
subplot(2,2,2),ezsurf(x,y,z,[0,2*pi,-0.5,0.5]),view(90,0);%侧视图
subplot(2,2,3),ezsurf(x,y,z,[0,2*pi,-0.5,0.5]),view(0,0);%正视图
subplot(2,2,4),ezsurf(x,y,z,[0,2*pi,-0.5,0.5]);%原图

 

 

 

2.6 三维图形绘制&2.7 四维图形绘制

 

 

2.6 三维图形绘制&2.7 四维图形绘制

 

 

2.6 三维图形绘制&2.7 四维图形绘制

 

>> [x,y,z]=sphere(50);
surf(x,y,z),hold on;x1=0.3*x+0.9;y1=0.3*y-0.8;z1=0.3*z+0.6;surf(x1,y1,z1)

>> z0=-1:0.1:3;
>> r=exp(-z0.^2/2).*sin(z0);
>> [x,y,z]=cylinder(r);
>> z=-1+4*z;%z默认(0,1),需要映射
>> surf(x,y,z)

 

2.6 三维图形绘制&2.7 四维图形绘制

 

 

>> [x,y]=meshgrid(-1:0.1:1,-2:0.1:2);
z=0.5457*exp(-0.75*y.^2-3.75*x.^2-1.5*x).*(x+y>1)+0.7575*exp(-y.^2-6*x.^2).*((x+y>-1)&(x+y<=1))+0.5457*exp(-0.75*y.^2-3.75*x.^2-1.5*x).*(x+y<=1);

>> h=surf(x,y,z),
subplot(2,2,1),contour(x,y,z);
subplot(2,2,2),[C,h]=contour(x,y,z);clabel(C,h);
subplot(2,2,3),contourf(x,y,z);
subplot(2,2,4),contour3(x,y,z,30);

 

 

 

2.6 三维图形绘制&2.7 四维图形绘制

 

f='x*sin(y+z^2)+y^2*cos(x+z)+z*x*cos(z+y^2)';
%syms x y z; f=x*sin(y+z^2)+y^2*cos(x+z)+z*x*cos(z+y^2);
%syms x y z; [email protected]*sin(y+z^2)+y^2*cos(x+z)+z*x*cos(z+y^2);
%三个任取一个
ezimplot3(f,[-1 1])
f1='x^2+y^2+z^2-1';
ezimplot3(f1,[-1 1])

 

2.6 三维图形绘制&2.7 四维图形绘制2.6 三维图形绘制&2.7 四维图形绘制

>> [x,y,z]=meshgrid(0:0.1:2);
V=sqrt(x.^x+y.^((x+y)/2)+z.^((x+y+z)/3));
slice(x,y,z,V,[1,2],[1,2],[0,1]);

2.6 三维图形绘制&2.7 四维图形绘制