% mygrid.m adds a grid for block matrix illustration....
% -------- assume block size n  (or nx, ny available)
%                 and a spy plot is done in a figure already
  if ~exist('n') | ~exist('nx')
    disp('Set nx = the first block size of a matrix')
    if ~exist('n')
      if ~exist('nx')
      return
      end
    else
      nx=n;
    end
  end
  if ~exist('ny'),ny=nx; end

drawnow; a=round(axis); 
disp(['  mygrid.m using block size : ' num2str(nx) ' x ' num2str(ny) ...
       ' (matrix sized ' num2str(a(2)-1) ' x ' num2str(a(4)-1) ')'])

for i=a(1):nx:a(2)
  hold on
  plot([i i]+0.5,a(3:4),'g')
end  % Hori

for i=a(3):ny:a(4)
  plot(a(1:2),[i i]+0.5,'r')
end  % Vert
  % clear ny
  hold off
