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](https://i.imgur.com/WGiTCy0.png)
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!