How pca() function works in matlab
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Atinesh Singh
am 11 Aug. 2016
Kommentiert: Walter Roberson
am 16 Aug. 2016
I'm trying to apply pca() function on 3d data, But I'm getting empty COEFF matrix
x1 = randn(400,1);
y1 = randn(400,1);
z1 = randn(400,1);
plot3(x1,y1,z1,'r.');
[COEFF] = pca([x1;y1;z1]')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155640/image.png)
0 Kommentare
Akzeptierte Antwort
Jason Millen
am 16 Aug. 2016
Bearbeitet: Jason Millen
am 16 Aug. 2016
The reason you are getting an empty 1200-by-0 matrix is because you are passing a 1-by-1200 matrix to pca.
I believe what you want to do is pass it a 400-by-3 matrix, which can be accomplished with [x1';y1';z1']'. Thus, if you call pca([x1';y1';z1']'), you will get a 3-by-3 coefficient matrix.
3 Kommentare
Jason Millen
am 16 Aug. 2016
I believe there is a transpose operator given before the matrix is passed into pca, making it 1-by-1200. Please correct me if I am wrong.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dimensionality Reduction and Feature Extraction finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!