function D = dec_deg_2_miles_vec(L)

%Takes locations in decimal-degree coordinates and calculates pairwise
%distances in miles. 

% INPUTS: L = (xi,yi) = (lon(i),lat(i)) decimal-degree coords.

%*******************************************************************
% NOTE: For the US, xi is NEGATIVE and yi is POSITIVE. Be sure they
%       are in the right order.
%*******************************************************************

% OUTPUT: D = nx(n-1)/2 vector of distinct pairwise distances

% DIST_VEC computes the vector of distinct pairwise distances
%          for a given location vector, loc.

%dbstop if warning

n = length(L(:,1)) ; % number of locations

%Compute pairwise distances

D = zeros(n*(n-1)/2, 1) ; %Matrix of pairwise distances

i = 1 ;

k = 1 ;  %counter for DD.

while i < n
   
   lon1 = L(i,1); 
   lat1 = L(i,2); 
   
   j = i + 1 ;
   
   while j <= n
      
      lon2 = L(j,1); 
      lat2 = L(j,2); 
      
      theta = lon1 - lon2;
      dist = sin(deg2rad(lat1)) * sin(deg2rad(lat2)) + ...
      cos(deg2rad(lat1)) * cos(deg2rad(lat2)) * cos(deg2rad(theta));
      dist = acos(dist);
      dist = rad2deg(dist);
      D(k) = dist * 60 * 1.1515;

      j = j + 1 ;
      
      k = k + 1 ;
      
   end
   
   i = i + 1 ;
   
end






