繁体   English   中英

如何在Matlab中绘制曲面?

[英]How do I plot a curved surface in matlab?

我正在尝试从管道上切出一个部分,并且想要制作一个弯曲的表面来代表管道的外部。 但是,当我绘制表面时,我只会得到表面的对角线,而不是表面本身。 我怎样才能解决这个问题?

MWE:

r = 0:0.1:3;
z = 0:0.1:10;  
[rr, zz] = meshgrid(r,z); 

% set cut planes angles
theta1 = 0;
theta2 = pi*135/180;
nt = 101;  % angle resolution

figure(1);
clf; 

t3 = linspace(theta1, (theta2 - 2*pi), nt);
[rr3, tt3] = meshgrid(r,t3);

% Create curved surface
xx5 = r(end) * cos(tt3);
yy5 = r(end) * sin(tt3);
h5 = surface(xx5, yy5,zz)

您创建的网格网格基于theta和半径。 但是,半径对于管道外部是恒定的,因此应基于theta和z,因为它们是定义网格的两个独立变量。 基于这种推理,我相信以下是您所追求的。

r = 0:0.1:3;
z = 0:0.1:10;  

% set cut planes angles
theta1 = 0;
theta2 = pi*135/180;
nt = 101;  % angle resolution

figure(1);
clf; 

% create a grid over theta and z
t3 = linspace(theta1, (theta2 - 2*pi), nt);
[tt3, zz3] = meshgrid(t3, z);
% convert from cylindical to Cartesian coordinates
xx5 = r(end) * cos(tt3);
yy5 = r(end) * sin(tt3);
% plot surface
h5 = surface(xx5, yy5, zz3, 'EdgeColor', 'none');

% extra stuff to make plot prettier
axis vis3d
axis equal
view(3)
camzoom(0.7);

在此处输入图片说明

尝试使用surf surf(xx5, yy5, zz)进行surf(xx5, yy5, zz) 这是你想要的?

冲浪图

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM