晚星 发表于 2013-1-15 18:55
谢谢epoh老师热心指教!谢谢xuehe版主热心参与!怎样绘制像MATLAB图标那样的实曲面3D图形呢?
不清楚你所谓的MATLAB实曲面3D图形,
猜猜你可能是要底下图形.
这是用matlab surf()画的
surf(X,Y,Z) creates a shaded surface using Z for the color data as well as surface height.
X and Y are vectors or matrices defining the x and y components of a surface.
这里X,Y可以是matrix
然gauss surface(x,y,z),x,y只能是vector,效果自然有差
x 1xK vector, the X axis data.
y Nx1 vector, the Y axis data.
z NxK matrix, the matrix of height data to be plotted.
matlab code:
- length=0.1;
- [X,Y]=meshgrid(-3:length:3);
- step=1+6/length;
- for i=1:step
- for j=1:step
- if (abs(X(i,j))<0.5) & (abs(Y(i,j))<0.5)
- Z(i,j)=0.0;
- else
- Z(i,j)=1.0/max(abs(X(i,j)),abs(Y(i,j)));
- end
- end
- end
- surf(X,Y,Z);
- view([2.2 1.2 3]);
- axis off
复制代码
gauss:
- library pgraph;
- graphset;
- _pdate = "";
- length=0.1;
- step=61;
- x=seqa(-3,length,61);
- y=seqa(-3,length,61);
- z=zeros(61,61);
- for i (1,step,1);
- for j (1,step,1);
- if (abs(x[i])<0.3) or (abs(y[j])<0.3);
- z[i,j]=0.0;
- else;
- z[i,j]=1.0/maxc(abs(x[i])|abs(y[j]));
- endif;
- endfor;
- endfor;
- surface(x',y,z);
复制代码