x=-10:0.1:10;y=x;z=x;
[x,y,z]=meshgrid(x,y,z);
f1=x.^2+y.^2+z.^2-4;
f2=x.^2+y.^2-1;
f3=x.^2+z.^2-1;
f4=z.^2+y.^2-1;
p1=patch(isosurface(x,y,z,f1,0));
set(p1, 'FaceColor', 'b', 'EdgeColor', 'none');
p2=patch(isosurface(x,y,z,f2,0));
set(p2, 'FaceColor', 'r', 'EdgeColor', 'none');
p3=patch(isosurface(x,y,z,f3,0));
set(p3, 'FaceColor', 'y', 'EdgeColor', 'none');
p4=patch(isosurface(x,y,z,f4,0));
set(p4, 'FaceColor', 'h', 'EdgeColor', 'none');
daspect([1 1 1])
view(3); axis tight
camlight;
lighting phong
图像出来之后,注意旋转一下图像3D,否则只能看到2维平面图。
本视频展示如何用matlab绘制散圆状态图,可用于相关科研数据绘图!
球面:
theta=linspace(0,pi);
phi=linspace(0,2*pi);
[tt,pp]=meshgrid(theta,phi);
[xx,yy,zz]=sph2cart(pp,pi/2.*ones(size(tt))-tt,4.*ones(size(tt)));
surf(xx,yy,zz)
axis square
shading flat
柱面:
theta=linspace(-pi/4,pi/4,100);
phi=linspace(0,2*pi,200);
[tt,pp]=meshgrid(theta,phi);
zz=tan(tt);
[xx,yy]=pol2cart(pp,ones(size(pp)));
surf(xx,yy,zz);
shading flat