Clear Filters
Clear Filters

Coloring of specific elements using trimesh

11 views (last 30 days)
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?

Accepted Answer

Kelly Kearney
Kelly Kearney on 23 Jun 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 Comment
David
David on 24 Jun 2015
Thanks Kelly! That was exactly was I was looking for! Thanks!

Sign in to comment.

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!