Depth Label of 3D Graph (Cylinder)

1 view (last 30 days)
Raysan Alhamoud
Raysan Alhamoud on 31 Jan 2018
Answered: Benjamin Kraus on 1 Feb 2018
I'm trying to graph a borehole using a set of depths and their respective diameters. I tried graphing it using:
r = [5,7,4,6,8,6,5,5,7,8]; [X,Y,Z]=cylinder(r); Surf(X,Y,X)
Which gave me a graph showing the diameters "r" on the x-y plane, but the z axis is always set to 1 (endpoints 0 to 1). How can I assign depths to each diameter of the graph.
e.g. (Z = [0,1,2,3,4,5,6,7,8,9])

Answers (1)

Benjamin Kraus
Benjamin Kraus on 1 Feb 2018
I would recommend ignoring the Z output from cylinder and just creating your own using meshgrid or ndgrid.
r = [5,7,4,6,8,6,5,5,7,8];
depths = [0,1,2,3,4,5,6,7,8,9];
[X,Y]=cylinder(r');
[~,Z] = meshgrid(1:size(X,2),depths);
[~,C] = meshgrid(1:size(X,2),r); % Color based on radius
surf(X,Y,Z,C)
If the data is upside down, just flip depths before calling meshgrid:
r = [5,7,4,6,8,6,5,5,7,8];
depths = [0,1,2,3,4,5,6,7,8,9];
[X,Y]=cylinder(r');
[~,Z] = meshgrid(1:size(X,2),flip(depths));
surf(X,Y,Z)

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!