How to plot midpoints between the points of circle ?
10 views (last 30 days)
Show older comments
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:
ae1=x1unit(6:10:s1*10);
be1=y1unit(6:10:s1*10);
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
ae11=x1unit(3:10:s1*10);
be11=y1unit(3:10:s1*10);
ae12=x1unit(6:10:s1*10);
be12=y1unit(6:10:s1*10);
ae13=x1unit(9:10:s1*10);
be13=y1unit(9:10:s1*10);
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
0 Comments
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');
3 Comments
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.
More Answers (0)
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!