%****************************************************************
%   This function computes the angle between two vectors x & y
%   in a n dimensional Euclidean Space in degrees. 
%   AUTHOR: Santhanam, Balu
%   DATE  : 04/12/99
%   USAGE :  phi = ang(x,y)
%****************************************************************
function phi = ang(x,y)
%  Error Checking Section
na_freq_x = find(isnan(x) == 1);
na_freq_y = find(isnan(y) == 1);
in_freq_x = find(isinf(x) == 1);
in_freq_y = find(isinf(y) == 1); 
if nargin ~= 2 
   error('Insufficient Input Information')
elseif length(x) == 0 | length(y) == 0
   error('Null Input')
elseif length(x) ~= length(y)
   error('Vectors need to have same dimension')
elseif any(x) == 0 | any(y) == 0 
   error('Input is a zero vector')
elseif length(na_freq_x) ~= 0 | length(na_freq_y) ~= 0
   error('Input contains NaN values')
elseif length(in_freq_x) ~= 0 | length(in_freq_y) ~= 0
   error('Input contains Inf values')
elseif isnumeric(x) == 0 | isnumeric(y) == 0
   error('Non--numeric input')
else 
%  Computation of the angle in degrees
   phi = (180/pi)*acos(dot(x,y)/(norm(x)*norm(y)));
end
return
