function dist_hist(varargin)
%function dist_hist(varargin)
%
% DIST_HIST  -- produces distance histogram plots given a number of
%               feature matrices, one for each distinct class
%
% Input Parameters:
%   <M1>  -- Each input parameter is a feature matrix (that is, a matrix
%             with one feature vector per row, and with as many columns as
%             the feature vectors have features) with features from a distinct
%             class.  Note that the function will accept any number of input
%             parameters.  Also note that the function will name the classes
%             based on the name of the input parameters
%
% Output Parameters:
%   None
%

means = {};
names = {};
d = {};

for i=1:length(varargin)
    means{i} = mean(varargin{i});
    names{i} = inputname(i);
end

for i = 1:length(varargin)
    for j= 1:length(varargin)
        d{i,j} = sqrt(sum((varargin{i}-repmat(means{j},[size(varargin{i},1),1])).^2,2));
    end
    figure(i);
    hist([d{i,:}],10);
    xlabel(['Distance of mean feature vectors from instances in ' names{i}]);
    ylabel('Number of instances');
    legend(names{:});
    colormap(pink);
end
