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. X是原始資料軍陣 coeff P*P,第i列對應第i個主成變換分向量 score:N*P,每個樣本的主成分表示 latent: coeff的協方差矩陣,也就是X的散度矩陣的特征值組成的對角陣 tsquare:returns Hotelling's T-squared statistic for each observation in X.