您的位置:首页 > 编程语言 > MATLAB

Matlab绘制三维曲面

2016-07-04 23:25 761 查看
平面网格点的生成

Matlab用meshgrid函数来生成x-y平面上的小矩形顶点坐标, 调用格式如下:

[X, Y] = meshgrid(x,y)

网格曲面

利用meshgrid生成网格点之后,可以用mesh来绘制网格曲面。

例子:

x = -8:0.5:8;
y = x;
[X, Y] = meshgrid(x, y);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
subplot(3,3,1), mesh(Z);
subplot(3,3,2), mesh(x, y, Z);
subplot(3,3,3), mesh(X, Y, Z);

subplot(3,3,4), meshc(Z);
subplot(3,3,5), meshc(x, y, Z);
subplot(3,3,6), meshc(X, Y, Z);

subplot(3,3,7), meshz(Z);
subplot(3,3,8), meshz(x, y, Z);
subplot(3,3,9), meshz(X, Y, Z);




实曲面

使用surf or surfl 替代mesh

例子:

x = -8:0.5:8;
y = x;
[X, Y] = meshgrid(x, y);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;

subplot(2,3,1), surf(Z);
shading faceted;

subplot(2,3,2), surf(x, y, Z);
shading flat;

subplot(2,3,3), surf(X, Y, Z);
shading interp;

subplot(2,3,4), surfl(Z);
shading faceted;

subplot(2,3,5), surfl(x, y, Z);
shading flat;

subplot(2,3,6), surfl(X, Y, Z);
shading interp;




end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  matlab 三维