Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
how can i create a circle using the equation below:
(x-a)^2+(y-b)^2 = r
Updated 23-Dec-13 4:51am
Richard MacCutchan 23-Dec-13 9:02am    
By plotting a set of points.

1 solution


Here's a simple explanation and then a solution :

1. The (a,b) is the center co-ordinate of the circle.

2. The (x,y) is any point on the circumference of the circle.

3. r is the radius of the circle.

4. Each Point on Circle = r*cos(angle), r*sin(angle)

Now, the MATAB code is here :

%define a, b, x and y
a = 3;
b = 4;
x = 6;
y = 7;

% Now we will find radius
r = (x-a)^2 + (y-b)^2;

% Now we will create a vector of angle range from 0 to 2*pi
theta = 0 : 0.01 : 2*pi;

% Now we will find x-points and y-points
xp = r * cos (theta);
yp = r * sin (theta);

% now we will plot the circle

axis 'square'
plot (xp + a, yp + b)

And you are done :

Hope that this explanation is satisfactory. Please do rate my answer and accept as answer if it solved your problem :)

With Regards
Tushar Srivastava
Share this answer
m.r.m.40 23-Dec-13 9:14am    
thank you,
I have several similar question, i'll add them in a minute.
m.r.m.40 23-Dec-13 9:33am
Thank you so much.
Richard MacCutchan 23-Dec-13 10:50am    
Instead of dumping your homework questions here, make an effort to do your own work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900