Finding eigen vectors of a matrix

조회 수: 4 (최근 30일)
Pouyan Msgn
Pouyan Msgn 2019년 7월 19일
답변: infinity 2019년 7월 25일
Hi I will use [V,D]=eigs(C,3,'LA') to get the three first eigenvectors of matrix C:
clear all
clc
N=5;
L=1;
h=L/N;
C=zeros(N+1,N+1);
C(1,1)=-1; C(1,2)=1;
C(N+1,N+1)=1;
A1=1/(h^2); A2=-2/(h^2); A3=1/(h^2);
for i=1:N-1
C(i+1,i)=A1;
C(i+1,i+1)=A2;
C(i+1,i+2)=A3;
end
M=C(2:N,2:N);
[V,D]=eigs(C,3,'LA');
But I get this error:
Error using eigs/checkInputs (line 864)
Eigenvalue range sigma must be a valid 2-element string.
For real symmetric A, the choices are 'LM', 'SM', 'LA', 'SA' or 'BE'.
For non-symmetric or complex A, the choices are 'LM', 'SM', 'LR', 'SR', 'LI' or 'SI'.
Error in eigs (line 93)
[A,Amatrix,isrealprob,issymA,n,B,classAB,k,eigs_sigma,whch, ...
Error in partiel3 (line 17)
[V,D]=eigs(C,3,'LA');
  댓글 수: 2
infinity
infinity 2019년 7월 19일
Hello,
In version 2018a, there is no any error. It get this
>> V
V =
0.0922 -0.6679 0.0391
0.1845 -0.5406 -0.3489
0.2841 -0.4091 -0.5986
0.3951 -0.2745 -0.6109
0.5219 -0.1378 -0.3810
0.6695 0 0
>> D
D =
1.0000 0 0
0 -0.1907 0
0 0 -9.9134
Maybe since your version is different.
But, you can try another approach like Maltab suggestion, for example,
For non-symmetric or complex A, the choices are 'LM', 'SM', 'LR', 'SR', 'LI' or 'SI'.
Since, in your case, C is not symmetric matrix.
Pouyan Msgn
Pouyan Msgn 2019년 7월 19일
So you mean that C must be equal to C' which is not in this case? I use 2015R

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

답변 (2개)

infinity
infinity 2019년 7월 25일
Thank for @Rik 's comment. I have moved my comment to this section.
Since Matlab response with these lines
Error using eigs/checkInputs (line 864)
Eigenvalue range sigma must be a valid 2-element string.
For real symmetric A, the choices are 'LM', 'SM', 'LA', 'SA' or 'BE'.
For non-symmetric or complex A, the choices are 'LM', 'SM', 'LR', 'SR', 'LI' or 'SI'.
It could be understood that
the function "eigs/checkInputs" in Matlab 2015R realize that your matrix C is not symmetric and you choice "LA" approach to find the eigvalue and eigenvector. This choise is not compatible with the type of C. Matlab also suggested you use appropriate method like "LM", "SM", .etc.
So, for your current version, you should change a bit like this
[V,D]=eigs(C,3,'LM'); % of SM, etc

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019년 7월 19일
Hi,
It works as expected. Just restart your MATLAB and re-run your code:
>> [V,D]=eigs(C,3,'LA')
V =
0.0922 -0.6679 0.0391
0.1845 -0.5406 -0.3489
0.2841 -0.4091 -0.5986
0.3951 -0.2745 -0.6109
0.5219 -0.1378 -0.3810
0.6695 0 0
D =
1.0000 0 0
0 -0.1907 0
0 0 -9.9134
  댓글 수: 1
Rik
Rik 2019년 7월 25일
Why would restarting Matlab do anything? The code already starts with the harsh 'clear all'. Have you tried this code on R2015b?
Since Trung VO DUY's comment points at the source of the issue and suggests a way to solve the problem, I think it should be moved to the answer section.

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

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by