How can I extract the Z data from a figure created using the patch function?
조회 수: 1 (최근 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!