load lincoln_mapquest_time.dat

n = size(lincoln_mapquest_time,1);

dissimilarities = lincoln_mapquest_time

opts = statset('Display','final','Maxiter',1000);

[coords,stress,disparities] = mdscale(dissimilarities, 2, 'Criterion',...
    'stress','Start','random','Replicates',20,'Options',opts)

plot(coords(:,1),coords(:,2),'ko')

for i = 1:n
    objectlabels{i,1} = int2str(i);
end

hold on

text(coords(:,1),coords(:,2),objectlabels,'fontsize',10,...
    'verticalalignment','bottom')

distances = pdist(coords);

disparities = squareform(disparities);

dissimilarities = squareform(dissimilarities);


figure(2)

[dum,ord] = sortrows([disparities(:) dissimilarities(:)]);

plot(dissimilarities,distances,'bo', ...
dissimilarities(ord),disparities(ord),'r.-');

xlabel('Dissimilarities'); ylabel('Distances/Disparities')

legend({'Distances' 'Disparities'},'Location','NW');


coords

stress

disparities = squareform(disparities)

lincoln_mapquest_time


