how to get basis vector from eigenvalues
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
sai charan sampara
2024-5-9
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!