MATLAB Answers

Plotting an Archimedean Spiral

261 ビュー (過去 30 日間)
Rajbir Singh
Rajbir Singh 2019 年 10 月 15 日
コメント済み: Rajbir Singh 2019 年 10 月 17 日
r = 12.5; %outer radius
a = 0; %inner radius
b = 0.01; %incerement per rev
n = (r - a)./(b); %number of revolutions
th = 2*n*pi; %angle
Th = linspace(0,th,1250*720);
x = (a + b.*Th).*cos(Th);
y = (a + b.*Th).*sin(Th);
plot(x,y)
The code executes well r, a, n and b are correct. Th and th both are also correct, but the problem which arises is in the values of x and y.
outer value or last value (desired) should be 12.5, but after execution it gives 78.53 and same corresponds to y.
what can be the solutions of this problem?

  5 件のコメント

表示 2 件の古いコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 10 月 15 日
Then what is the problem?
Rajbir Singh
Rajbir Singh 2019 年 10 月 15 日
Sir,
The output which i am getting is an Archimedean Spiral, thats fine. But the problem arises with the output values x and y.
According to the software that i am using r, a, n, b, th and Th values are correct.
My desired outer radius for archemedean spiral is 12.5 but it gives 78.53
Rajbir Singh
Rajbir Singh 2019 年 10 月 16 日
How can i change the rotation (clockwise or anti-cloclwise) of Archimedean Spiral?

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

採用された回答

Jos (10584)
Jos (10584) 2019 年 10 月 15 日
In the computation of x and y you wrongly multiply b with Th. You should multipy by Th / (2*pi):
r = 12.5; %outer radius
a = 0; %inner radius
b = 0.5; %incerement per rev % Jos: changed to see the spiral!!
n = (r - a)./(b); %number of revolutions
th = 2*n*pi; %angle
Th = linspace(0,th,1250*720);
x = (a + b.*Th/(2*pi)).*cos(Th);
y = (a + b.*Th/(2*pi)).*sin(Th);
% better:
% i = linspace(0,n,1250*720)
% x = (a+b*i).* cos(2*pi*i)
plot(x,y)
[x(end) y(end)]

  4 件のコメント

表示 1 件の古いコメント
Rajbir Singh
Rajbir Singh 2019 年 10 月 16 日
How can i change the rotation (clockwise or anti-cloclwise) of Archimedean Spiral?
Jos (10584)
Jos (10584) 2019 年 10 月 16 日
hint: use a minus sign :-)
Rajbir Singh
Rajbir Singh 2019 年 10 月 17 日
It works, thanks once again. :)

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by