这是我用matlab做作业时蹦出来的灵感,通过对原本的函数调参,构造出来了具有空间感和美感的图像。
1
2
3
4
5
这就是我当时做的题。
6
下面是源代码
x=0:0.01:1; % a范围
y=0:0.01:1; % b范围
[xx,yy]=meshgrid(x,y); %构成格点矩阵
c=(yy-1+sqrt((yy-1).^2+xx))./2; %计算x
z=-xx.*c+sqrt((xx.*c).^2+yy); %计算z
cmap = gray(6);
subplot(2,2,1)
surf(xx,yy,z);title('Surfplot'); %子图1,绘制三维图形
subplot(2,2,2)
mesh(xx,yy,z);title('Meshplot'); %子图2,绘制三维曲面
subplot(2,2,3)
surf(xx,yy,z);title('Surplot with shading interp'); %子图3,绘制三维曲面,表面为光滑
shading interp;
subplot(2,2,4)
contour(xx,yy,z);title('Meshplot'); %子图4,绘制等高曲线