plotting an N segments circle
Show older comments
Hi all,
I am trying to plot an N segments shape using this line of code:
N =10;
theta = (0: (2*pi)/N : 2 * pi) ;
theta_centers = (pi/2: (2*pi)/N : 4*pi) ; % this is to find the centers of the prevoius line
xb = 0.02*sin(theta) ;
yb = 0.02*cos(theta) ;
xbc = 0.02*sin(theta_centers) ; % to find the centers of xb
ybc = 0.02*cos(theta_centers) ;
plot(xb,yb,'r',xbc,ybc,'o')
%%%%%%
after running this code, the 'o' are not on the main function lines....
WHY?
thanks
Accepted Answer
More Answers (1)
Al Alothman
on 21 Mar 2019
0 votes
1 Comment
Star Strider
on 21 Mar 2019
As always, my pleasure!
My code only does the circumference one time. (The plot looks really strange otherwise.) If you want it to start at pi/2 (or any other angle), add that value to the ‘theta’ vector created by linspace:
theta = linspace(0, 2*pi, N) + pi/2;
The rest of my code remains the same. (The polygon then rotates by the added angle.)
Categories
Find more on Surfaces, Volumes, and Polygons 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!


