% close all
clear all
%-----------------------------------
 disp('Mahalanobis Distance on Rao''s Cork Data')
  lw = 2; 
  set(0, 'DefaultAxesFontSize', 17);
  fs = 17;
  msize = 5;
% MAHALANOBIS DISTANCE ON RAO's CORK DATA
%
close all
 load 'C:\STAT\Descriptive\Descriptivedat\cork.dat'
 X = cork(:,2:3);
 plot(X(:,1),X(:,2),  'ro')
   hold on
   plot(mean(X(:,1)),mean(X(:,2)), 'ko','markersize',10)
   dist = mahal(X,X); % Mahalanobis distance for each case
  [dist I] = sort(dist);
  dist = flipud(dist); % distances in descending order
  I = flipud(I);
  I(1:5); % indices of  cases with 5 largest distances
  x = X(I(1:5),1);
  y = X(I(1:5),2); 
  
  
 text(x,y, cellstr(num2str(sqrt(dist(1:5)))))
