Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Mohamad Al Hassan
Mohamad Al Hassan le 24 Jan 2019
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

Réponses (1)

Star Strider
Star Strider le 24 Jan 2019
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.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by