print a circular disk onto my graph
12 views (last 30 days)
Show older comments
Hi! I now work in a project to simulate the solarsystem on a very simple level. The assingment is to plot the path of orbit of the planets and to plot a sketched sun in the center. It feels like a simple thing but i cant manage to figure out how to do it. are there any comands that can plot circles or discs? it should symbolize the sun so it has to be filled. Any suggestions?
Im looking forward for answers.
Kind regards, Viktor
0 Comments
Accepted Answer
Adam Danz
on 15 Apr 2019
Edited: Adam Danz
on 17 Apr 2019
Ironically, you can use the rectangle() function with 100% curvature to plot a circle.
The position property specifies the lower, left corner of the rectangle, not the center of it, along with the width and height (in this case, diameter). So if you'd like your circle centered at (0,0) with a diameter of 10, you'll need to subtract 10/2 from (0,0) in order to specify the lower, left "corner" of the rectangle.
Be sure to set axes to 'equal' so the aspect ratio depicts a circle.
center = [0,0];
diameter = 10;
figure
h = rectangle('Position',[center-diameter/2, diameter, diameter],'Curvature',[1,1], 'FaceColor', 'y', 'EdgeColor', 'k');
axis equal
More Answers (1)
See Also
Categories
Find more on 2-D and 3-D Plots 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!