Asked by Rajbir Singh
on 15 Oct 2019

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?

Answer by Jos (10584)
on 15 Oct 2019

Accepted Answer

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)]

Rajbir Singh
on 16 Oct 2019

How can i change the rotation (clockwise or anti-cloclwise) of Archimedean Spiral?

Jos (10584)
on 16 Oct 2019

hint: use a minus sign :-)

Rajbir Singh
on 17 Oct 2019

It works, thanks once again. :)

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 5 Comments

## KALYAN ACHARJYA (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/485508-plotting-an-archimedean-spiral#comment_756616

## Rajbir Singh (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/485508-plotting-an-archimedean-spiral#comment_756617

## KALYAN ACHARJYA (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/485508-plotting-an-archimedean-spiral#comment_756618

## Rajbir Singh (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/485508-plotting-an-archimedean-spiral#comment_756622

## Rajbir Singh (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/485508-plotting-an-archimedean-spiral#comment_756771

Sign in to comment.