How to plot an hexagon or square spiral shape ?

5 ビュー (過去 30 日間)
Zeinab Ahmadi93
Zeinab Ahmadi93 2017 年 7 月 8 日
編集済み: DGM 2025 年 1 月 14 日
Hello I am trying to plot an spiral shape similar to one of the following figures(There is no difference, I need one of them, plooting in simple(solid) line is enough for me, I don't need markers on them) but I have no idea how to do it in matlab. Thanks in advance.

採用された回答

darova
darova 2020 年 6 月 14 日
try ths
t = 0:pi/2:100;
r = t.^2/100;
[x,y] = pol2cart(t,r);
plot(x,y)
pi/2 pi/4
  1 件のコメント
DGM
DGM 2025 年 1 月 14 日
編集済み: DGM 2025 年 1 月 14 日
A bit of elaboration:
% parameters
nt = 15; % number of turns
ns = 6; % number of polygon sides
r0 = 1; % initial (maximum) radius
rp = 2; % controls the rate with which r decreases
th0 = 90; % initial angle
theta = (nt*2*pi:-2*pi/ns:0) + (pi*th0/180);
rho = r0*(theta/max(theta)).^rp;
[x,y] = pol2cart(theta,rho);
plot(x,y,'.-')
axis equal square

サインインしてコメントする。

その他の回答 (1 件)

jonatan
jonatan 2017 年 7 月 8 日
It is best to be solved in polar coordinates. For a simple square, you can show the relationship:
theta = 0:0.01:2*pi;
rho = min(abs(sec(t)), abs(csc(t)));
So if you want to create a spiral, you will need a small adjustment:
N = 10; %Number of spirals
theta = 0:0.01:2*pi*N;
rho = min(abs(sec(t)), abs(csc(t))) * theta;
You now can plot it using polarplot or convert it to Cartesian coordinates and using the regular plot function.
  1 件のコメント
Örs Istok
Örs Istok 2020 年 6 月 2 日
sorry but what is t?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by