15,908,768 members
See more:
Hi,
how can i create a circle using the equation below:
(x-a)^2+(y-b)^2 = r
Posted
Updated 23-Dec-13 4:51am
v2
Richard MacCutchan 23-Dec-13 9:02am
By plotting a set of points.

## Solution 1

Alright,

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 :

With Regards
Tushar Srivastava

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
http://www.codeproject.com/Questions/701033/math-equation-MATLAB
http://www.codeproject.com/Questions/701032/math-equation-MATLAB
Thank you so much.
Richard MacCutchan 23-Dec-13 10:50am