function logpaper(n, ny)
%
% Function logpaper(n,ny)
%
% usage:
% logpaper    produces 4-cycle semi-log paper, with
%             70 horizontal grid lines.
% logpaper(n) produces semi-log graph paper of  n  cycles
%             with 70 horizontal grid lines.
% logpaper(n,ny) produces semi-log graph paper of  n  cycles
%                and ny horizontal 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 of bold grid lines
figure % open new plot

% number of cycles and horizontal grid lines:
if nargin>2 then
   disp('please use logpaper')
   disp('       or  logpaper(cycles)')
   disp('       or  logpaper(cycles,horiz grids)')
   disp(' ')
elseif nargin==1
   ny=70;
elseif nargin==0
   n=4; ny=70;
end

% x-axis points for vertical grid lines in first decade:
xone=[1:10];
x=xone;
if n>1
   % x-axis points for vertical grid lines in other decades:
   for i=2:n
      x=[x  xone(2:10)*10^(i-1)];
   end
end

% need to plot zero and 1 on the y-axis at each point:
hold off
semilogx([x(1) x(1)],[0 1]); % first vertical gridline
hold on 
for i=2:length(x) % now plot other vertical grids:
   semilogx([x(i) x(i)],[0 1]);
end

% now add horizontal grid lines:
% bold zero axis:
line([x(1) x(length(x))],[0  0],'linewidth',boldwdth);
for i=1:ny % other lines
   if  rem(i,10)==0 % make every tenth line bold:
      line([x(1) x(length(x))],[i/ny  i/ny],'linewidth',boldwdth);
   else
      plot([x(1) x(length(x))],[i/ny  i/ny]);
   end
end
title('Top')
axis('off')
hold off