Calculating dominant eigenvector for each matrix in a large array
Show older comments
Hi,
I am trying to write a for loop to make an array of dominant eigenvectors for each of the matrices in a 11 X 11 X 10,000 array. My problem is in decoupling the V of the [V,D] = eig(A). I hope the below code can give an idea of what I am trying to do, but please let me know if I need to be more clear about anything.
LHS_matrices;
R_EIGENVECTORS = zeros(nstages,1,nsample);
for k = 1:nsample
[V,D] = eig(LHS_MATRICES(:,:,k));
R_EIGENVECTORS(:,1,k) = V(:,1);
end
That code runs, but all of the eigenvector outputs are the same, and seem to be incorrect, e.g.:
val(:,:,1) =
0
1
0
0
0
0
0
0
0
0
0
val(:,:,2) =
0
1
0
0
0
0
0
0
0
0
0
The below code was perfect for determining the dominant eigenvalue for population growth rate (I am a conservation biologist). If anyone knows of something like this I could use to determine the dominant eigenvectors (and thus the stable population distribution), that would be amazing!
LHS_matrices;
EIGENVALUES = zeros(nsample,1);
for k = 1:nsample
EIGENVALUES(k,1) = max(abs(eig(LHS_MATRICES(:,:,k))));
end
6 Comments
the cyclist
on 3 Apr 2020
Can you upload your data in a mat file (using the paper clip icon), or a representative sample that illustrates the issue?
Jenna Parker
on 3 Apr 2020
David Goodmanson
on 4 Apr 2020
Hi Jenna,
be aware that the eigenvalues produced by eig are not necessarily sorted, so the largest one might not be first.
Jenna Parker
on 5 Apr 2020
David Goodmanson
on 5 Apr 2020
HI Jenna, Since the nth column belongs with the nth listed eigenvalue in the diagonal eigenvalue matrix, and those values can be in arbitrary order, the first column is not always dominant. It's not like the svd.
Jenna Parker
on 6 Apr 2020
Answers (0)
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!