To perform principal component analysis in Matlab, you can use the built-in function pca
. Here is an example usage:
main.m841 chars26 lines
Note that coeff
contains the principal component coefficients (eigenvectors), score
contains the projected data onto the principal component axes, and latent
contains the eigenvalues of the covariance matrix of the data.
You can also use the pcares
function to perform PCA with data scaling and centering, and the pcaresplot
function to visualize the results of PCA.
main.m377 chars13 lines
gistlibby LogSnag