Inconsistent EigenVectors on running same problem multiple times

조회 수: 11 (최근 30일)
Rehan Rehan
Rehan Rehan 2016년 1월 9일
댓글: Steven Lord 2016년 1월 11일
Hi All,
In my FEM code, I run EIG or EIGS command for getting eigenvalues and eigenvectors. Strangely, it is returning different eigenvectors that are inconsistent each time for the same code and same inputs.
Any help will be appreciated.
Best regards,

답변 (1개)

Walter Roberson
Walter Roberson 2016년 1월 9일
If I recall, a few weeks ago someone mentioned that there is a random initialization going on (might have been by at the qr level.) Try setting the random seed, trying, setting it again, see if you get the same results.
  댓글 수: 9
Guillaume
Guillaume 2016년 1월 11일
No, as has been said, you can fix the seed of RNG to the same number before each time you call eigs, so that the 'random' number it uses is always the same and thus, always returns the same result.
As per Walter's later comment:
rng(12345); %use any seed you want
[A1,B1] = eigs(KM,20,'sm');
rng(12345); %as long as it's always the same
[A2,B2] = eigs(KM,20,'sm');
Steven Lord
Steven Lord 2016년 1월 11일
Or set the v0 option in your EIGS call to fix the starting vector. By default, it is randomly generated.

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

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by