Effacer les filtres
Effacer les filtres

Coloring of specific elements using trimesh

11 vues (au cours des 30 derniers jours)
David
David le 23 Juin 2015
Commenté : David le 24 Juin 2015
Hi,
I'm using trimesh to plot a triangular mesh having all nodal positions stored in x,y,z and a corresponding nodal connection vector in Tri, generating a mesh following the trimesh-command as:
m = trimesh(Tri,X,Y,Z);
I understand how to use the handle m to change e.g. 'FaceColor' and 'EdgeColor' to a specific RGB-value. However, now I would like to color specific elements differently from the whole mesh. I.e. I have a list of all nodal points 'belonging' to a specific color and would like to somehow fix that using the trimesh-handle.
Anyone have an idea on how to achieve that?

Réponse acceptée

Kelly Kearney
Kelly Kearney le 23 Juin 2015
I think the easiest way to do this would be to simply create two separate meshes, one that includes all points and one that only includes the ones you want to treat specially.
[x,y] = meshgrid(1:15,1:15);
tri = delaunay(x,y);
z = peaks(15);
isspecial = rand(size(tri,1),1) < 0.1;
trimesh(tri,x,y,z, 'facecolor', 'interp', 'edgecolor', 'k')
hold on
trimesh(tri(isspecial,:),x,y,z, 'facecolor', 'r')
  1 commentaire
David
David le 24 Juin 2015
Thanks Kelly! That was exactly was I was looking for! Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by