# Plotting an Archimedean Spiral

조회 수: 146(최근 30일)
Rajbir Singh 2019년 10월 15일
편집: Leroy Tyrone 2023년 2월 8일
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표시숨기기 이전 댓글 수: 4
Rajbir Singh 2019년 10월 16일
How can i change the rotation (clockwise or anti-cloclwise) of Archimedean Spiral?

댓글을 달려면 로그인하십시오.

### 채택된 답변

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):
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)]
##### 댓글 수: 5표시숨기기 이전 댓글 수: 4
Leroy Tyrone 2023년 2월 8일
편집: Leroy Tyrone 2023년 2월 8일
@ Jos Is it possible to return which revolution in 'n' that each value in 'Th' belongs to? Alnd also to plot the points as equidistant by assigning a variable 's' as arc length?

댓글을 달려면 로그인하십시오.

### 범주

Find more on Programming in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by