function v = maxphi1(phi,y,m,n) dims = repmat([m],[1 n]); yy = repmat(y,[m 1]); %xx = repmat([1:m]',[1 m]); xy = [[1:m]' yy]; xind = coord2ind(xy,dims); [v, ind] = max(phi(xind)); return