Get non-zero eigenvalues and eigenvectors

I am simply looking to retrieve non-zero eigenvalues (and eigenvectors which correspond to them) from a matrix X. I am new to matlab and the eig() and eigs() functions don't seem to do what I want. How do I solve this?

댓글 수: 2

madhan ravi
madhan ravi 2018년 11월 25일
upload your matrix and what's the desired result?
Fraser Price
Fraser Price 2018년 11월 25일
편집: Fraser Price 2018년 11월 25일
For example for the matrix [1 2; 3 4] we have
X = [1 2; 3 4]
[V,L] = eig(X)
V =
-0.7071 -0.7071
0.7071 -0.7071
L =
1 0
0 0
But I only want L to contain non-zero eigenvalues and V to contain just the eigenvectors which correspond to them, i.e.
V =
-0.7071
0.7071
L =
1
I hope this is clear.

댓글을 달려면 로그인하십시오.

답변 (1개)

Christine Tobler
Christine Tobler 2018년 11월 26일

0 개 추천

You could just remove the zero eigenvalues after computing them:
>> X = [1 1; 1 1]
X =
1 1
1 1
>> [V,l] = eig(X, 'vector')
V =
-0.7071 0.7071
0.7071 0.7071
l =
0
2
>> l == 0
ans =
2×1 logical array
1
0
>> V(:, l==0) = []
V =
0.7071
0.7071
>> l(l==0) = [];
l =
2
In practice, l==0 should probably be replaced by abs(l) < tol.

카테고리

도움말 센터File Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품

질문:

2018년 11월 25일

답변:

2018년 11월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by