function polpaper(nc,n)
%
% Function polpaper(nc,n)
%
% Usage:
% polpaper     produces polar graph paper with 50 circular
%              grid lines and radial lines every 10 degrees.
% polpaper(nc) Produces polar graph paper with  nc circular
%              grid lines and radial lines every 10 degrees.
% polpaper(nc,n) Produces polar graph paper with  nc
%                circular grid lines and radial grid lines
%                every n degrees. In this mode, be careful
%                of making n too small, as the program only
%                does a little to reduce the congestion that
%                results in the centre, and does nothing to
%                provide variable enboldening of grid lines.
% (You may have to edit the "boldwdth" parameter in the script
%  to get acceptable results for enboldened grid lines on
%  your particular printer - but don't rely on screen appearance!)

% Ken Dutton, 1998

boldwdth=1.0;  % width for bold gridlines
figure % open new plot
if nargin>2
   disp('please use polpaper')
   disp('       or  polpaper (circles)')
   disp('       or  polpaper(circles,radials)')
   disp(' ')
elseif nargin==1
   % radial grid lines every how many degrees?
   n=10;
elseif nargin==0
   nc=50;n=10;
end
% points for circular grid line of radius 1:
th=[0:2*pi/200:2*pi];

% circular grid lines:
for i=1:nc
   if rem(i,5)==0  % make fifth lines bold
      line(i/nc*cos(th),i/nc*sin(th),'linewidth',boldwdth)
   else
      if i==1
         hold on
      end
      polar(th, i/nc*ones(size(th))) % easier way to plot lines!
   end
end

% radial grid line angles:
rg=pi/180*[0:n:179];
if n>=10 %degrees
   % plot radial lines (0.04 gap in centre to avoid congestion):
   for i=1:length(rg)
      if rem((i-1),3)==0  % make third lines bold
         line([-cos(rg(i)) -0.04*cos(rg(i))],...
            [-sin(rg(i)) -0.04*sin(rg(i))],'linewidth',boldwdth)
         line([cos(rg(i)) 0.04*cos(rg(i))],...
            [sin(rg(i)) 0.04*sin(rg(i))],'linewidth',boldwdth)
      else
         polar([rg(i) rg(i)],[-0.04 -1]);
         polar([rg(i) rg(i)],[0.04  1]);
      end
   end
else  % excessive number of radial lines therefore
      % use 0.04 gap in centre of some lines and 0.16
      % gap in the centre of others to avoid congestion:
   for i=1:length(rg)
      if rem((i-1),3)==0 % make third lines bold and to centre
         line([-cos(rg(i)) -0.04*cos(rg(i))],...
            [-sin(rg(i)) -0.04*sin(rg(i))],'linewidth',boldwdth)
         line([cos(rg(i)) 0.04*cos(rg(i))],...
            [sin(rg(i)) 0.04*sin(rg(i))],'linewidth',boldwdth)
      else  % make other lines shorter
         polar([rg(i) rg(i)],[-0.16 -1]);
         polar([rg(i) rg(i)],[0.16  1]);
      end
   end
end    
  
axis('square')
axis('off')
hold off