wrapping a value onto 3D surface of an irregular pipe
6 次查看(过去 30 天)
显示 更早的评论
Dear all,
I have generated the following 3D plot showing the surface of an irregular cylinder.
The plot was created from the known X, Y and Z coordinate (the data is attached to this post in three separate *.txt files)
I used the following iteration to generate the plot:
xori = load('Xhole.txt');
yori = load('Yhole.txt');
depth = load('Depth.txt');
figure('Position',[100,50,800,600]);
plot3(yori,xori,-1*depth+0*xori,'color',[.5 .5 .5]);hold on
for ii = 1:length(depth)
plot3(yori(ii,:),xori(ii,:),-1*depth(ii)+0*xori(ii,:),'k-');
hold on
view([65 -90 90]);
xlabel('x');
zlabel('Depth (z)');
ylabel('y');
set(gca,'DataAspectRatio',[1 1 3.5]);
axis tight
set(gca,'XTickLabel',[]);
set(gca,'YTickLabel',[]);
end
I got two questions now:
Is there any other workaround to generate a similar plot that is more elegant than the above code?
Suppose I have the 4th-dimension, i.e. values at each X-Y-Depth pair, how do I wrap the value onto the 3D plot? I am thinking of generating a plot shown below:
0 个评论
采纳的回答
darova
2020-3-4
编辑:darova
2020-3-4
Here is the succesfull solution
X = load('Xhole.txt');
Y = load('Yhole.txt');
Z = load('Depth.txt');
Z = repmat(Z,[1 180]);
R = hypot(X,Y);
cla
surf(X,Y,Z,'edgecolor','none','facecolor','interp');
alpha(0.4)
hold on
surf(X./R*5,Y./R*5,Z,'cdata',R);
hold off
axis vis3d
caxis([min(R(:)) max(R(:))])
Colored according to radius
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!