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!