How can I write a function that draws a regular polygon with n sides in a cartesian plot?
이전 댓글 표시
How can I write a function that draws a regular polygon with n sides and radius 1 in a cartesian plot?
답변 (2개)
Steven Lord
2020년 3월 9일
1 개 추천
Use nsidedpoly to create a polyshape then plot that polyshape.
Star Strider
2020년 3월 9일
Easily, actually.
N = 5; % Number Of Sides
a = linspace(0, 2*pi, N+1); % Angle Vector
r = 1; % Radius Vector
phi = pi/4; % Phase (Rotates Figure)
x = r*cos(a + phi);
y = r*sin(a + phi);
figure
plot(x, y,'-r', 'LineWidth',1.5)
axis equal
I assume that this is not homework.
카테고리
도움말 센터 및 File Exchange에서 Polygonal Shapes에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!