![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275125/image.png)
wrapping a value onto 3D surface of an irregular pipe
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274912/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274913/image.jpeg)
0 Kommentare
Akzeptierte Antwort
darova
am 4 Mär. 2020
Bearbeitet: darova
am 4 Mär. 2020
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275125/image.png)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!