P=[3 6 7 6 2 5 7 0 5 9 5 7 2 7 5 3 1 3 5 7;8 6 6 5 6 0 0 8 8 7 9 1 9 0 2 7 9 5 3 5;8 9 9 7 8 10 9 1 4 2 7 9 4 7 9 6 3 4 1 8;3 3 9 3 1 1 7 6 4 5 2 9 2 4 2 5 3 9 2 5;10 7 2 9 4 2 4 10 9 1 4 6 8 4 8 6 2 10 6 8;6 1 1 9 8 6 9 4 2 10 3 4 5 6 3 4 2 2 1 1;2 2 7 5 7 10 1 7 3 4 6 4 2 0 2 9 8 8 7 10;5 9 3 5 8 5 4 9 10 4 8 4 5 5 3 7 3 3 4 5;0 4 7 9 6 5 7 6 6 5 6 5 7 8 7 4 5 2 6 8;0 3 9 6 3 2 3 1 9 9 7 2 6 10 5 8 3 1 1 4]; alpha=0; [optimValue, optimPath]=myPlateauPass(P, alpha); fprintf('optimValue=%g\n', optimValue); fprintf('optimPath=%s\n', mat2str(optimPath)); % Plotting [m, n]=size(P); imagesc(1:n, 1:m, P); axis image; shading flat; colorbar title('Plateau'); for i=1:n line(i, optimPath(i), 'color', 'k', 'marker', '.'); end