MATLAB Answers

How to plot midpoints between the points of circle ?

14 views (last 30 days)
Eleni agou
Eleni agou on 17 Sep 2018
Edited: Eleni agou on 18 Sep 2018
I draw a circle with s1=4 points.
I have this code
t1 = 0:(pi/(5*s1)):2*pi; % s1 is the number of points I want to have on the circle
x1unit = r1 * cos(t1) + x1;
y1unit = r1 * sin(t1) + y1;
a1=x1unit(1:10:s1*10); % is xi for my circle
b1=y1unit(1:10:s1*10); %is yi
plot(x1unit, y1unit, 'b', x1, y1, 'ok');%circle with the center x1,y1
plot(a1, b1, 'o'); % x,y for s1 times my points
if I want to add one point right in the middle, between to other points(a1,b1) I use this code:
So, I have one midpoint [s1=4, (1-2,2-3,3-4,4-1) ] . I want more midpoints, for example three or n,if it is possible .
If I want 3 points i use this code
but I don't like this way. Maybe there is more practical way with less code.
My plot is the following picture.Ignore the inner circle. I would like 9 green points,instead one.
like the 3 blue dots,like in the picture:
How I have 9 points which equidistant between the s1 points ???
Thanks in advance


Sign in to comment.

Accepted Answer

Jan on 17 Sep 2018
Edited: Jan on 17 Sep 2018
Create the coordinates of the wanted points directly:
x1 = 0;
y1 = 0;
r1 = 1;
n = 3; % Points per quadrant
t2 = linspace(0, 2*pi, 4 *(n+1) + 1);
t2(end) = []; % Do not draw last point twice
xx2 = r1 * cos(t2) + x1;
yy2 = r1 * sin(t2) + y1;
plot(xx2, yy2, 'o');


Eleni agou
Eleni agou on 17 Sep 2018
I have one more circle in this way.I want only the points between the x points, like the 2on image.
Thanks for your answer.
Jan on 18 Sep 2018
My code does not draw an additional circle. If you see a circle, you are using a different code. Of course you have to adjust the values for x1, y1, r1, which I had guessed, because you did not provide them.
Eleni agou
Eleni agou on 18 Sep 2018
I create points with this code:
and I want to add points, between (a1,b1)i and i=1:s1. If I correct my t1 with yours(t2) I have an error about my table with my points. My Error is:
Index exceeds matrix dimensions. Error in circle17_9 (line 24) a1=x1unit(1:10:s1*10);
so I thought to do this
and the code runs. But I have not midpoints.
I want to ask you about the logic for this:
t2 = linspace(0, 2*pi, 4 *(n+1) + 1);
is 0-2pi ,for draw a circle. n is the points I want. and 4*(n+1)+1 is because you divide a circle to 4 quadrant??
I want to calculate 2 different equations. One for midpoints and one for the first(s1) points. In my icons, one for blue dots and one for x points.So, I need something to find only the x points and then olny midpoints between x on my circle.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!