how to get basis vector from eigenvalues
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi Guys,
I have i have just calculated the eigenvalue:
[V, D] = eig(B)
where previously B = cov(A) gave me a 5x5matrix.
How do i get the 2 basis vectors belonging to axes with the greatest variance? And how to get their corresponding variances?
0 commentaires
Réponses (1)
sai charan sampara
le 9 Mai 2024
Hello,
You can get the 2 basis vectors by simply sorting the eigen values in decreasing order and then usig the sorted indexes to index through the eigen vectors and get the vectors with the 2 largest eigen values as the basis vectors. The same is done in singular value decomposition done by "svd" function in MATLAB. Here is an example code:
A=randi(5,5);
B=cov(A)
[V,D]=eig(B)
[sorted_eigenvalues, idx] = sort(diag(D), 'descend')
sorted_eigenvectors = V(:, idx);
basis_vector_1 = sorted_eigenvectors(:, 1)
basis_vector_2 = sorted_eigenvectors(:, 2)
[U,S,V] = svd(B)
basis_vector_1 = U(:, 1)
basis_vector_2 = U(:, 2)
0 commentaires
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!