Borrar filtros
Borrar filtros

how to draw a regular polygon with polarplot command?

5 visualizaciones (últimos 30 días)
Hakyoon Kim
Hakyoon Kim el 16 de Dic. de 2022
Respondida: KSSV el 16 de Dic. de 2022
how to draw a regular polygon with polarplot command?
i'll use input command for n and R.
(n is the number of vertices, R is the distance between the vertex and the center)
conditions are
  1. center is 0,0
  2. the distance between vertex and center is R.
  3 comentarios
Hakyoon Kim
Hakyoon Kim el 16 de Dic. de 2022
Editada: Hakyoon Kim el 16 de Dic. de 2022
sorry i forgot the code
prompt_n=('Input n what you want(n>=3): ');
prompt_R=('Input R what you want(R>0): ');
na=input(prompt_n);
R=input(prompt_R);
n=round(na);
theta = 0:pi/90:2*pi;
pgon = nsidedpoly(n,'Center',[0,0]);
if n>3
plot(pgon)
hold on
polarplot(theta,R)
else
disp('끝냅시닷:p');
end
Hakyoon Kim
Hakyoon Kim el 16 de Dic. de 2022
After drawing the polygon, I tried to write holdon on the polar coordinates, but it didn't work

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 16 de Dic. de 2022
Convert polar coordinates to cartesian and then plot.
prompt_n=('Input n what you want(n>=3): ');
prompt_R=('Input R what you want(R>0): ');
na=input(prompt_n);
R=input(prompt_R);
n=round(na);
theta = 0:pi/90:2*pi;
pgon = nsidedpoly(n,'Center',[0,0]);
x = R*cos(theta) ;
y = R*sin(theta) ;
if n>3
plot(pgon)
hold on
plot(x,y)
else
disp('끝냅시닷:p');
end

Más respuestas (0)

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by