From the documentation for eigs
:
d = eigs(A)
returns a vector of the six largest magnitude eigenvalues of matrix A.
If you want all seven, you need to call d = eigs(A,7)
or d = eig(A)
. For a small matrix (e.g. < 1000 x 1000) it's usually easier to just get all the eigenvalues with eig
, rather than get a subset with eigs
.
Edit: Responding to your "Update 3"
for k=1:length(D)
should be replaced by for k=1:n
. This needs to be changed on two lines. Judging from your error message they are lines 231 and 236.
L = length(X)
returns the length of the largest array dimension in X
, which in your case is 7, i.e. too high for the first dimension.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…