How can I write the values of a colourmap on each object?

1 visualización (últimos 30 días)
Pasquale
Pasquale el 10 de Nov. de 2017
Comentada: Pasquale el 11 de Nov. de 2017
I have a mesh of triangular elements and a figure obtained with trisurf(tri,x,y,z). I insert the colorbar, where each colour represents the height z of triangles. Is it possible to write and display all the z values on the corresponding triangle?

Respuesta aceptada

KSSV
KSSV el 11 de Nov. de 2017
N = 10 ;
x = rand(N,1) ;
y = rand(N,1) ;
z = rand(N,1) ;
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
mx = mean(x(tri),2) ;
my = mean(y(tri),2) ;
mz = mean(z(tri),2) ;
trisurf(tri,x,y,z) ;
colorbar
view(2)
hold on
text(mx,my,mz,num2str(mz))

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by