Structure mesh: plot different regions with different colors

Hi all,
I have a 2D mesh with different regions, like this:
I generated a mesh for this beam
Is there a way to highlight the 2 circles with different colors?
Many thanks!

2 comentarios

KSSV
KSSV el 27 de Sept. de 2017
Yes..it can be....how you have data? Attach the data here.
Please see the .mat file for data. data.node is the nodal info, data.elem is connectivity, data.region1 is the coordinates for the left circular region, data.region2 is the coordinates for the right circular region. I'd like to use different color to denote these regions. Thank you!

Iniciar sesión para comentar.

 Respuesta aceptada

KSSV
KSSV el 28 de Sept. de 2017
load data.mat ;
tri = data.elem ;
coor = data.node ;
x = coor(:,1) ; y = coor(:,2) ; z = coor(:,3) ;
patch('faces',tri(:,2:4),'vertices',coor , ...
'facevertexcdata' , z, ...
'facecolor','interp', ...
'edgecolor','none') ;
hold on
c1 = data.region1 ;
c2 = data.region2 ;
patch(c1(:,1),c1(:,2),c1(:,3),'r')
patch(c2(:,1),c2(:,2),c2(:,3),'b')

6 comentarios

Matlab gave me this figure (in the attachment) which does not seem correct?. I'd like to have edges of the mesh as well.
Change the edgecolor option to the color you want.
patch('faces',tri(:,2:4),'vertices',coor , ...
'facevertexcdata' , z, ...
'facecolor','interp', ...
'edgecolor','k') ;
It gave me this?
KSSV
KSSV el 28 de Sept. de 2017
Rotate the figure.....you can change it's orientation....
KSSV
KSSV el 28 de Sept. de 2017
Editada: KSSV el 28 de Sept. de 2017
tri = data.elem ;
coor = data.node ;
x = coor(:,1) ; y = coor(:,2) ; z = coor(:,3) ;
trisurf(tri(:,2:4),coor(:,2),coor(:,3),coor(:,3))
view(2) ;
c1 = data.region1 ;
c2 = data.region2 ;
ylim([-20 40])
patch(c1(:,2),c1(:,3),c1(:,3),'r')
patch(c2(:,2),c2(:,3),c2(:,3),'b')
It can be fine tuned to get all elements of circles and plot them in our own color....
This is much better, thanks a lot for your help!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 27 de Sept. de 2017

Comentada:

el 28 de Sept. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by