![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174163/image.png)
how to plot a single valued function over a triangulated surface?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ahmad
am 25 Apr. 2016
Kommentiert: ahmad
am 25 Apr. 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 Kommentare
Akzeptierte Antwort
Mike Garrity
am 25 Apr. 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.
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174163/image.png)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!