% Draws a spiral
% J.M.Soler. Sept.2010

% Set plot parameters
clear all
r_min = 0.1;                % minimum radius
r_max = 1;                  % maximum radius
n_turns = 10;               % number of turns
n_points = 100*n_turns;     % number of points to draw

% Find points to draw
delta_angle = 2*pi*n_turns / n_points;   % angle increment
delta_r = (r_max - r_min) / n_points;    % radius increment
angle = 0 : delta_angle : 2*pi*n_turns;  % angle of each point
r = r_min : delta_r : r_max;             % radius of each point
x = r .* cos(angle);                     % x coordinates. Notice '.*'
y = r .* sin(angle);                     % y coordinates

% Draw the points
figure(1)
plot(x,y,'LineWidth',1.5)
axis( [-1.1*r_max, 1.1*r_max, ...   % Lower and upper limits of x axis
       -1.1*r_max, 1.1*r_max] )     % Lower and upper limits of y axis
axis equal                          % Make x and y tics equally separated
title('A nice spiral')
xlabel('x'); ylabel('y')
set(gca,'FontSize',15)
