# How do i obtain only the first principal component?

10 Ansichten (letzte 30 Tage)
sidra am 1 Okt. 2013
Beantwortet: Andrew Knyazev am 12 Aug. 2018
For certain measurements i need to obtain only the numeric value of the first principal component from the matrix. Can someone please tell me how do i go about it?
##### 1 KommentarKeine anzeigenKeine ausblenden
sidra am 23 Okt. 2013
Any suggestions?

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Jan am 23 Okt. 2013
Bearbeitet: Jan am 23 Okt. 2013
I'm not sure, if I fully understand your question. I doubt however, that there is a straightforward method for calculating the eigenvector corresponding to the largest eigenvalue of the covariance matrix without calculating all eigenvalues first (at least not for non-sparse matrices).
If you want the first principal component of the (m x n)-matrix A containing m measurements as row vectors you would in general do the following:
A = randn(100, 20); % artificial sample matrix
c_A = cov(A);
[V, ~], eigs( c_A );
p_1 = V( :, 1 );
which gives you the direction of the first principal component in the variable p_1.
##### 1 KommentarKeine anzeigenKeine ausblenden
sidra am 29 Okt. 2013
Thank you so much jan :)

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Andrew Knyazev am 12 Aug. 2018
https://www.mathworks.com/matlabcentral/fileexchange/48-lobpcg-m can be used as the method for calculating the eigenvector corresponding to the largest eigenvalue of the covariance matrix without calculating all eigenvalues, or even without explicitly calculating the covariance matrix itself.
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

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!

Translated by