function h = permutecells(g,p,m2)

h = ones(size(g)) ;

for j = 1:length(p) ;
  h(mindices(p(j))) = g(mindices(j)) ;
end
