function [T,P,varexp] = pca(X,no_of_lv)
%  Principal component analysis by SVD
[n,m] = size(X);
cov = (X*X');
[u,s,v] = svd(cov);
v = X'*v;
% for i = 1:n
%     v(:,i) = v(:,i)/norm(v(:,i));
% end
PCnumber = (1:n)';

individualExpVar = diag(s)*100/(sum(diag(s)));
varexp  = [PCnumber individualExpVar cumsum(individualExpVar)];
P  = v(:,1:no_of_lv);
T = X*P;
end