Matlab 第九次打卡

mac2024-08-22  58

Task 09:三维图

语法知识

1.书写格式:plot3(X,Y,Z),X,Y,Z为同维的向量
2.三维条形图:

3.三位散点图:

4.三维网格图:

5.三维网格图:
6.建议表面图:

7.柱形立体图:

实例演练

>> t=0:pi/50:10*pi; >> x=0.1*exp(t/20).*cos(2*t); >> y=0.1*exp(t/20).*sin(2*t); >> plot3(x,y,t),grid on

>> year=[1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001]; >> GDP=[17.4 19.58 23.94 31.38 43.8 57.73 67.79 74.77 79.55 83.05 89.4 95.93]; >> consu=[3.1 3.4 10.7 19.6 24.8 16.5 8.3 2.8 -0.8 -1.4 0.4 0.7]; >> colormap(spring) >> bar3(year,GDP,0.3) >> figure >> colormap([0 1 1]) >> bar3(year,consu,0.3)

编辑器:

for n=0:0.5:15 r=5+5*n; theta=0:pi/12:2*pi; x=r*cos(theta); y=r*sin(theta); z=50*ones(size(x))*n-2*n.^2; c(1)=0;c(2)=0;c(3)=0; scatter3(x,y,z,3,c,'filled') hold on end axis([-80,80,-80,80,0,320])

命令窗口:

>> fountain_prog

>> [X,Y]=meshgrid(-3:0.2:3); >> Z=exp(-X.^2-Y.^2).*sin(X).^2; >> mesh(X,Y,Z) >> title('Z = exp(-X.^2 - Y.^2).*sin(X).^2,的网格图'); >> xlabel('X'); >> ylabel('Y'); >> zlabel('Z'); >> axis([-3,3,-3,3,0,0.3]) >> max(max(Z)) ans = 0.2713

最新回复(0)