MATLAB Answers

plotting circles

조회 수: 2,918(최근 30일)
How can I plot circles, same radius and different centers, all in one graph. I used the following command to draw +,o,diamond: plot (x,y,'ro',u,v,'gd',A,B,'b+'); where x,y,u,v,A,B are all row vectors. And I want to add circles to that plot where the o will be the center.
  댓글 수: 1
fatima ibrahim
fatima ibrahim 29 Feb 2020
function draw_circle1(x,y,R,c)
t =0:0.05:6.28;
x1 = (x +R*cos(t))';
y1= (x +R*sin(t))';

댓글을 달려면 로그인하십시오.

채택된 답변

Paulo Silva
Paulo Silva 12 Mar 2011
Here's a function to draw circles:
function circle(x,y,r)
%x and y are the coordinates of the center of the circle
%r is the radius of the circle
%0.01 is the angle step, bigger values will draw the circle faster but
%you might notice imperfections (not very smooth)
If you want to add circles you must insert the command
hold on
before the circles being added.
  댓글 수: 8
Özgür Saglam
Özgür Saglam 3 May 2020
Thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변(4개)

Michelle Hirsch
Michelle Hirsch 29 Jan 2016
It's counter-intuitive, but this is actually really easy with the rectangle function. From the rectangle documentation :
pos = [2 4 2 2];
rectangle('Position',pos,'Curvature',[1 1])
axis equal
  댓글 수: 3
Image Analyst
Image Analyst 14 Apr 2016
rectangle() is one of several methods listed in the FAQ:> You'll have lots of other nice improvements that they've made over the last 5 years if you upgrade.

댓글을 달려면 로그인하십시오.

Image Analyst
Image Analyst 5 Jul 2012

Chad Greene
Chad Greene 21 Aug 2014
This'll do the job.

Image Analyst
Image Analyst 20 Jan 2016

Community Treasure Hunt

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

Start Hunting!

Translated by