Plotting level sets of a function on a triangulated surface.
Afficher commentaires plus anciens
I want to plot the level sets of one function g(x,y,z) as curves on an isosurface f(x,y,z)=c. The following code comes close, but I need help getting over the finish line.
[x,y,z] = meshgrid(-1:.025:1);
f = x.^2 +y.^2 + z.^2;
g = x.^2 - y.^2;
c = 0.8
[faces,verts,colors] = isosurface(x,y,z,f,c,g);
patch('Vertices',verts,'Faces',faces,'FaceVertexCData',colors,...
'FaceColor','interp','EdgeColor','none')
view(3)
axis equal
colormap(turbo(10))

In this example code, we can see the level sets as the boundaries between the colored regions, but what I really want is
- Curves on a solid-colored sphere
- The ability to choose which values of g(x,y,z) get plotted
- The ability to choose line styles, colors, and thicknesses
1 commentaire
Roy Goodman
le 3 Juil 2025
Modifié(e) : Roy Goodman
le 13 Jan 2026
Réponse acceptée
Plus de réponses (1)
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


