PCA in Matlab reduce dimensionality
100 views (last 30 days)
Show older comments
I just want to have a simple PCA to reduce my dimensionality of let say 400 * 5000 to 400 * 4
meaning reduce from 5000 to 4.
I am not sure where can i set the value of reduction.
coeff = pca(X)
I am trying to follow:
load hald
Then:
The dataset of ingredient is 13 * 4

coeff = pca(ingredients)
Output:
coeff = 4×4
-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
I am wondering can i change it to output of 13 *2
Accepted Answer
Elysi Cochin
on 20 Feb 2019
[coeff, score] = pca(ingr);
requiredResult = score(:,1:2);
or if you want to change coeff to 13 x 2 matrix, you'll have to use reshape function, but to use reshape your variable coeff must have atleast 13 x 2 elements
or you can use repmat, it will repeat copies of the array coeff
More Answers (0)
See Also
Categories
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!