print a circular disk onto my graph

조회 수: 11 (최근 30일)
Viktor Edlund
Viktor Edlund 2019년 4월 15일
편집: Adam Danz 2019년 4월 17일
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

채택된 답변

Adam Danz
Adam Danz 2019년 4월 15일
편집: Adam Danz 2019년 4월 17일
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

추가 답변 (1개)

Image Analyst
Image Analyst 2019년 4월 15일
See the FAQ: Click Here

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by