如何在matlab中绘制曲面?

时间:2018-05-25 19:48:15

标签: matlab surface

我正在尝试从管道中切出来,我想制作一个曲面来代表管道的外部。然而,当我绘制表面时,我只得到表面的对角线而不是表面本身。我该如何解决这个问题?

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)

2 个答案:

答案 0 :(得分:2)

您创建的网格网格基于θ和半径。但是,半径对于管道外部是恒定的,因此它应该基于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);

enter image description here

答案 1 :(得分:0)

尝试使用surf surf(xx5, yy5, zz)。这是你在找什么?

surf plot

相关问题