function ng = ij2n (i,j) global N1 N2 if(N1 < N2) ng = i + (j-1)*N1; else ng = j + (i-1)*N2; endif endfunction