How can I extract the Z data from a figure created using the patch function?

2 次查看(过去 30 天)
Consider the following small example:
x=[0 1 0;1 1 0];
y=[0 0 1;0 1 1];
z=[0 1 0.5;1 0.5 0.5];
colormap(jet)
patch(x',y',z','FaceColor','interp','EdgeColor','interp');
Is there a way to read the z data on the graph with the data cursor (I know I can add a legend but I want to obtain the exact value of z at certain points, I also know that z will not be exact it's an approximation obtained by inteerpolation but yea you get the point)? It appears I can olny read the x and y coordinates of the points without the amplitude of z at that point. For example I can obtain the cordinates of the bottom left corner in the following picture but I can't know what is z I can only estimate it by adding a legend.
WGiTCy0.png

回答(1 个)

Star Strider
Star Strider 2019-1-24
The code you posted does not actually create 'ZData':
hp = patch(x',y',z','FaceColor','interp','EdgeColor','interp');
xd = get(hp, 'XData')
yd = get(hp, 'YData')
zd = get(hp, 'ZData')
shows:
xd =
0 1
1 1
0 0
yd =
0 0
0 1
1 1
zd =
[]
If you also use:
view(3)
you see that it is a plane, not a surface.

类别

Help CenterFile Exchange 中查找有关 Polygons 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by