function [z]=PCA(data)
% Function PCA performs principal component analysis. 
% It defines the principal components for the given data.
% 
% Input
%   data    Data matrice, which should have at least three columns.
%
% Output
%   z       Matrice of eigenvectors which corresponding eigenvalues are biggest.
%
% Authors: Anu Niemi, Annemari Auvinen

[m n] = size(data);
if (n < 3)
    error('Data matrice should have at least three colums');
end
c=cov(data);
[v, d]=eig(c);
z = [v(:,n) v(:,n-1) v(:,n-2)];