pca() not working as advertised

8 views (last 30 days)
Alexander Tarroni
Alexander Tarroni on 22 Nov 2016
Commented: Image Analyst on 4 Apr 2020
When consulting the documentation for the pca() function, I tried the following example:
load hald
The ingredients data has 13 observations for 4 variables.
Find the principal components for the ingredients data.
load hald
coeff = pca(ingredients)
coeff =
-0.0678 -0.6460 0.5673 0.5062
-0.6785 -0.0200 -0.5440 0.4933
0.0290 0.7553 0.4036 0.5156
0.7309 -0.1085 -0.4684 0.4844
The rows of coeff contain the coefficients for the four ingredient variables, and its columns correspond to four principal components.
However on my machine, I get this output for the same commands:
load hald
coeff = pca(ingredients)
coeff =
517.7969
67.4964
12.4054
0.2372
Does anyone know why this is happening? I am running the latest version of Matlab r2016b on Ubuntu 16.04

Answers (1)

KSSV
KSSV on 22 Nov 2016
Try
[pc,score,latent,tsquare] = princomp(ingredients);
  5 Comments
XiXi Liu
XiXi Liu on 4 Apr 2020
通过命令: which -all princomp 或者 which -all pca
查看pca/princomp都有哪些路径;
会显示至少两个有该函数的路径,因此造成冲突;
手动删除其中的某个路径,尽量保留Matlab 工具箱的路径。
Image Analyst
Image Analyst on 4 Apr 2020
princomp() was removed from the Statistics and Machine Learning Toolbox in R2019a.
In r2020a:
load hald
coeff = pca(ingredients)
coeff =
-0.0678 -0.64602 0.56731 0.50618
-0.67852 -0.019993 -0.54397 0.49327
0.029021 0.75531 0.40355 0.51557
0.73087 -0.10848 -0.4684 0.48442

Sign in to comment.

Categories

Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!