clf; format compact; format long g;

data = load('Dataz-JTSK.txt');
y = data(:,2);
x = data(:,3);
data(:,5) = sqrt (x.^2+y.^2);
data(:,6) = sqrt ( (9e5-x).^2+(8e5-y).^2 );
poc = sortrows (data,5);
bod = sortrows (data,6);

fprintf ('Nejblize k pocatku:\n' )
fprintf ('       CB        Y            X         H      distance\n')
fprintf ('% 9.0f |% 10.2f |% 11.2f |% 8.2f |% 8.2f\n', poc(1:5,[1:4,5])')
fprintf ('\nNejblize k bodu [800000,900000]:\n')
fprintf ('% 9.0f |% 10.2f |% 11.2f |% 8.2f |% 8.2f\n', bod(1:5,[1:4,6])')

prehledka = plot (data(:,2), data(:,3), 'xr');
% h .. handle aktualniho grafu
h = gca;
set (h, 'XAxisLocation', 'top',   'XDir', 'reverse', ...
        'YAxisLocation', 'right', 'YDir', 'reverse' );
