Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

plotting circles

Asked by Yasmine Tamimi

Yasmine Tamimi (view profile)

on 12 Mar 2011
Latest activity Commented on by Firas

Firas (view profile)

on 29 Dec 2014

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.

0 Comments

Yasmine Tamimi

Yasmine Tamimi (view profile)

Products

No products are associated with this question.

5 Answers

Answer by Paulo Silva

Paulo Silva (view profile)

on 12 Mar 2011
Accepted answer

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)
ang=0:0.01:2*pi; 
xp=r*cos(ang);
yp=r*sin(ang);
plot(x+xp,y+yp);
end

If you want to add circles you must insert the command

hold on

before the circles being added.

1 Comment

Firas

Firas (view profile)

on 29 Dec 2014

That's awesome

Paulo Silva

Paulo Silva (view profile)

Answer by Yasmine Tamimi

Yasmine Tamimi (view profile)

on 12 Mar 2011

Thanx a lot

0 Comments

Yasmine Tamimi

Yasmine Tamimi (view profile)

Answer by Ahmet

Ahmet (view profile)

on 28 May 2012

i did not run it can you help me? i copied and pasted to the editor but it did not run

1 Comment

Anurag

Anurag (view profile)

on 5 Jul 2012

define x=0,y=0 and r=some constant

Ahmet

Ahmet (view profile)

Answer by Image Analyst

Image Analyst (view profile)

on 5 Jul 2012

0 Comments

Image Analyst

Image Analyst (view profile)

Answer by Chad Greene

Chad Greene (view profile)

on 21 Aug 2014

This'll do the job.

0 Comments

Chad Greene

Chad Greene (view profile)

Contact us