% file: euclidean.m
%
% function to determine the Euclidean distances between a point
% and two set means.  It then determines the set membership based upon these 
% two distances
% Must be used from the file homework_02.m

function out=euclidean(x1,m1,m2,x2,output_file)

% check to see if 3 or 4 arguments passed in
%
if nargin < 5
  % compute distances
  %
  output_file=x2;
  d1=dist(x1,transpose(m1));
  d2=dist(x1,transpose(m2));
else
  % compute distances based on a separate transform space
  %
  d1=dist(x1,transpose(m1));
  d2=dist(x2,transpose(m2));
end

% determine set membership for x1
%
if abs(d1-d2)<1*10^-9
   fprintf(output_file,' is equal distance from set1 and set2\n');
elseif d1>d2
   fprintf(output_file,' belongs to set2\n');
else
   fprintf(output_file,' belongs to set1\n');
end

% return computed distances
%
out=[d1 d2];