matlab主成分分析的函数是 princomp,位于statistical tool box里。它的用法如下 :
[coeff, score, latent, tsquare] = princomp(x,econFlag)
x是样本矩阵,行是样本,列是特征。设 x为 N*P.
ecnoFlag:默认是0
% When X has more variables than observations, the default behavior is to
% return all the pc's, even those that have zero variance. When econFlag
% is 'econ', those will not be returned.
% return all the pc's, even those that have zero variance. When econFlag
% is 'econ', those will not be returned.
X是原始数据军阵
coeff P*P,第i列对应第i个主成变换分向量
score:N*P,每个样本的主成分表示
latent: coeff的协方差矩阵,也就是X的散度矩阵的特征值组成的对角阵
tsquare:returns Hotelling's T-squared statistic for each observation in X.