使用matlab:绘制z=sin(x)*cos(y)的三维网格和三维曲面图,x,y变化范围均为[0,2π]。
时间: 2024-05-30 15:15:36 浏览: 26
代码如下:
```matlab
% 定义x,y范围
x = linspace(0, 2*pi, 50);
y = linspace(0, 2*pi, 50);
% 生成网格点
[X,Y] = meshgrid(x,y);
% 计算z值
Z = sin(X) .* cos(Y);
% 绘制网格图
figure;
mesh(X,Y,Z);
xlabel('x');
ylabel('y');
zlabel('z');
title('3D Mesh of z=sin(x)*cos(y)');
% 绘制曲面图
figure;
surf(X,Y,Z);
xlabel('x');
ylabel('y');
zlabel('z');
title('3D Surface of z=sin(x)*cos(y)');
```
运行结果如下图所示:
![3D Mesh of z=sin(x)*cos(y)](https://cdn.luogu.com.cn/upload/image_hosting/tw1e7p7p.png)
![3D Surface of z=sin(x)*cos(y)](https://cdn.luogu.com.cn/upload/image_hosting/ew7zbi9g.png)