pca() not working as advertised
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
KSSV
2016-11-22
Try
[pc,score,latent,tsquare] = princomp(ingredients);
5 个评论
XiXi Liu
2020-4-4
通过命令: which -all princomp 或者 which -all pca
查看pca/princomp都有哪些路径;
会显示至少两个有该函数的路径,因此造成冲突;
手动删除其中的某个路径,尽量保留Matlab 工具箱的路径。
Image Analyst
2020-4-4
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
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!