function [FeatureMatrix, ElapsedTime] = ...
    plot_wine(m,PlotFlag)

%Input arguments:
%---------------
%
%m - (1 x 1) the size of feature space (chosen by the user)
%
%PlotFlag - (1 x 1) if PlotFlag = 1 create plot, otherwise don't

to = clock;

if PlotFlag == 1  
  close all
end

load wine.mat  % wine data
Train = Data(:,1:end-1);
TrainMemship = Data(:,end);


%%% no. of class
C = length(unique(TrainMemship));

%%% find prior
for i=1:C
  p(i)=length(find(TrainMemship==i-1))/length(TrainMemship);
end

% Feature Extraction using AIDA                                    
T =aida(Train,TrainMemship, p, m);  
FeatureMatrix=T;



FeatureTrain = (Train * T');

if PlotFlag == 1
  
  Kolor = colormap;
  Ind = 1:floor(64/C):64;

  for i = 1:C
    ind = find(TrainMemship == (i-1));
  
    if m == 1
      ph = plot(FeatureTrain(ind), zeros(length(ind),1),'ko');
      hold on
    elseif m == 2
      ph = plot(FeatureTrain(ind,1), FeatureTrain(ind,2),'ko');
      hold on
    elseif m >= 3
      ph = plot3(FeatureTrain(ind,1),FeatureTrain(ind,2), ...
                 FeatureTrain(ind,3),'ko');
      hold on
    end
    set(ph,'Color',Kolor(Ind(i),:),'MarkerSize',6, ...
           'MarkerFaceColor', Kolor(Ind(i),:))
  end
  
  if m > 1
    set(gca,'DataAspectRatio',[1 1 1])
  end
  
end
et = etime(clock,to);
disp(['Elapsed time: ' num2str(et)])
ElapsedTime = et;