# how to plot a single valued function over a triangulated surface?

1 visualización (últimos 30 días)
ahmad el 25 de Abr. de 2016
I have a finite element mesh [t,p] for a surface in 3D, where t is the triangles and p is the (x,y,z) coordinates of the vertices. For instance the mesh for the unit sphere from http://persson.berkeley.edu/distmesh/. I'm using the Matlab command patch('Faces',t,'Vertices',p,'edgecol','r'); to visualize this mesh. The question is how to plot a function defined over this triangulated surface?
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Mike Garrity el 25 de Abr. de 2016
You can do it with patch. You'll just want to set FaceColor to interp and set the FaceVertexCData to to value of your function.
But you might find it easier to use the trisurf function. Here's a simple example:
npts = 100;
x = 2*randn(npts,1);
y = 2*randn(npts,1);
z = peaks(x,y);
c = z;
tri = delaunay(x,y);
h = trisurf(tri,x,y,z,c,'FaceColor','interp');
colormap(parula(12))
axis tight
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
ahmad el 25 de Abr. de 2016
Thanks a lot. That's exactly what I was looking for, i.e., setting FaceColor to interp and FaceVertexCData to the value of the function. However, I'm not sure if trisurf would give the required answer.

Iniciar sesión para comentar.

### Categorías

Más información sobre Surface and Mesh Plots 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!

Translated by