How can I extract the Z data from a figure created using the patch function?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.

0 comentarios
Respuestas (1)
Star Strider
el 24 de En. de 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.
0 comentarios
Ver también
Categorías
Más información sobre Polygons en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!