Want a random matrix which has a negative eigenvalues
Show older comments
I want to generate an mxm (here I am showing a 3x3) matrix such that each element is an integer of some reasonable magnitude (let's say between 1 and 10) and who's eigenvalues are all negative. At first I did this to generate a random matix:
C = randi(10,3,3)
eig(C)
I reran this about 40 times and never got three negative eigenvalues. That seems odd. I could get every combination except all three being negative. Wouldn't the odds of that would be low. Is there something I don't understand about "randi" or worse, something I don't undertand about eigenvalues?
Accepted Answer
More Answers (2)
David Goodmanson
on 17 Nov 2018
Edited: David Goodmanson
on 17 Nov 2018
1 vote
Hi Jon,
The sum of the eigenvalues of a matrix equals the trace of the matrix. If all eigenvalues are negative their sum would be negative, but with rand(10,n,n) supplying only positive elements, the trace is positive. So you can't have all negative eigenvalues.
1 Comment
Jon Games
on 17 Nov 2018
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!