I would like to plot an interpolated 3d Surface between two faces, i.e. the third face of a truncated cone. my plot isn't working but I'm not sure what is wrong

4 次查看(过去 30 天)
r1=0.5;
% t1=[(0:0.1:2*pi),0];
t1=0:0.1:2*pi;
X1=r1*cos(t1);
Y1=r1*sin(t1);
n1=numel(X1);
Z1=zeros(1,n1);
DT=delaunay(X1,Y1);
trisurf(DT,X1,Y1,Z1);
hold;
r2=0.25;
% t2=[(0:0.1:2*pi),0];
t2=0:0.1:2*pi;
X2=r2*cos(t2);
Y2=r2*sin(t2);
n2=numel(X2);
Z2=200*ones(1,n2);
DT2=delaunay(X2,Y2);
trisurf(DT2,X2,Y2,Z2);
X= [X1,X2];
Y=[Y1,Y2];
Z=[Z1,Z2];
[xq,yq]=meshgrid(X,Y);
zq=ones(126).*Z;
surf(xq,yq,zq);

采纳的回答

Star Strider
Star Strider 2024-6-19
TThis does not look like a cone to me at all.
What do you want to do?
r1=0.5;
% t1=[(0:0.1:2*pi),0];
t1=0:0.1:2*pi;
X1=r1*cos(t1);
Y1=r1*sin(t1);
n1=numel(X1);
Z1=zeros(1,n1);
DT=delaunay(X1,Y1);
trisurf(DT,X1,Y1,Z1);
hold;
Current plot held
r2=0.25;
% t2=[(0:0.1:2*pi),0];
t2=0:0.1:2*pi;
X2=r2*cos(t2);
Y2=r2*sin(t2);
n2=numel(X2);
Z2=200*ones(1,n2);
DT2=delaunay(X2,Y2);
trisurf(DT2,X2,Y2,Z2);
X= [X1,X2];
Y=[Y1,Y2];
Z=[Z1,Z2];
[xq,yq]=meshgrid(X,Y);
zq=ones(126).*Z;
surf(xq,yq,zq);
view(-27,30)
My approach to a truncated cone (assuming my interpretation matches yours), woudl be something like this —
r = [1; 2]; % Radius Multipliers
h = [0; 3]; % Height Multipliers
a = linspace(0, 2*pi); % Angle Vector
cyl = [cos(a); sin(a)] % Circles
cyl = 2x100
1.0000 0.9980 0.9920 0.9819 0.9679 0.9501 0.9284 0.9029 0.8738 0.8413 0.8053 0.7660 0.7237 0.6785 0.6306 0.5801 0.5272 0.4723 0.4154 0.3569 0.2969 0.2358 0.1736 0.1108 0.0476 -0.0159 -0.0792 -0.1423 -0.2048 -0.2665 0 0.0634 0.1266 0.1893 0.2511 0.3120 0.3717 0.4298 0.4862 0.5406 0.5929 0.6428 0.6901 0.7346 0.7761 0.8146 0.8497 0.8815 0.9096 0.9341 0.9549 0.9718 0.9848 0.9938 0.9989 0.9999 0.9969 0.9898 0.9788 0.9638
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
figure
surf(r*cyl(1,:), r*cyl(2,:), h.*[ones(size(a)); ones(size(a))], 'FaceColor','b', 'FaceAlpha',0.5) % Plot Cone
hold on
patch((r(1)*cyl(1,:)), (r(1)*cyl(2,:)), ones(size(a))*h(1), 'r') % Plot Lower Cap
patch(r(2)*cyl(1,:), r(2)*cyl(2,:), ones(size(a))*h(2), 'g') % Plot Upper Cap
hold off
grid on
axis('equal')
view(-27,30)
This is my interpretation of a truncated cone with end-caps.
.
  6 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by