% routine to position subplots
function subpos(nrow,ncol,i);
%
% i   is the subplot index
% nrow is "how many rows of plots"
%
yinc=(1/nrow)*0.8;
%xinc=(1/ncol)-.01;
xinc=(1/ncol)*0.8;

% find x&y position
xp=rem(i-1,nrow)*xinc+.2*rem(i-1,nrow)+.05;
yp=nrow*yinc-yinc-floor((i-1)/ncol)*yinc+.05;
set(gca,'position',[xp yp xinc yinc]);

% remove unnecessary label
if rem(i,ncol)~=1;
  ylabel(' ');
  set(gca,'yticklabels',' ');
end;
if i<nrow*ncol-ncol+1;
  xlabel(' ');
  set(gca,'xticklabels',' ');
end;
