Coloured circles on a mesh
Show older comments
I managed to get two coloured boxes on the mesh

I am struggling to imagine how I could get the circles with three different colours on this mesh

Any suggestions are most welcome.
Accepted Answer
More Answers (1)
Benjamin Kraus
on 9 Jun 2025
Edited: Benjamin Kraus
on 9 Jun 2025
What approach did you use to draw the rectangles?
The easiest approach to drawing circles in MATLAB is using the rectangle command and setting the Curvature to 1. This can only be used to draw circles in the X/Y plane, which looks (from your picture) like what you are trying to do.
rectangle('Position',[0 0 1 1],'Curvature',1,'FaceColor','green')
view(3)
grid on
box on
If you need circles in another plane, you have two options:
figure
h = hgtransform('Matrix',makehgtform('xrotate',pi/2));
rectangle(h,'Position',[0 0 1 1],'Curvature',1,'FaceColor','green')
view(3)
grid on
box on
Option 1b: You can also use an hgtransform to translate your circle if you need it somewhere other than at Z=0.
figure
h = hgtransform('Matrix',makehgtform('translate',[0 0 1]));
rectangle(h,'Position',[0 0 1 1],'Curvature',1,'FaceColor','green')
view(3)
grid on
box on
figure
t = linspace(0,2*pi,361);
x = zeros(size(t));
y = cos(t);
z = sin(t);
fill3(x,y,z,'g')
view(3)
Categories
Find more on Graphics Object Programming 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!


