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!