function [i,j]=index(n,imax)
%function [i,j]=index(n,imax)
%                        n is one dim index, i and j are 2 dim, with matrix
%                             of imax rows  ( size(matrix) )
[im,jm]=size(imax);
if (im>1)&(jm>1)
      imax=im;
end
i=1+rem(n-1,imax);
j=ceil(n/imax);
