plotting an N segments circle
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
Al Alothman
am 21 Mär. 2019
0 Stimmen
1 Kommentar
Star Strider
am 21 Mär. 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.)
Kategorien
Mehr zu Surfaces, Volumes, and Polygons finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



