Is there an easy way to generate random matrices, all with eigenvalues that I'll choose?
Asked
Active
Viewed 591 times
1 Answers
3
Given a diagonal matrix containing all the eigenvalues you want, you can use a similarity transformation of a random (but invertible) matrix to do what you want:
>> lambda = [-1 -2 -3] % These are the eigenvalues you want
lambda =
-1 -2 -3
>> A = diag(lambda)
A =
-1 0 0
0 -2 0
0 0 -3
>> eig(A)
ans =
-3
-2
-1
>> S = rand(size(A)); % Random matrix of compatible size with A.
>> B = inv(S)*A*S % Random matrix with desired eigenvalues, using similarity transformation
B =
-2.7203 -0.5378 -0.9465
2.0427 -0.1766 1.2659
-2.0817 -1.8974 -3.1031
>> eig(B)
ans =
-3.0000
-1.0000
-2.0000

Kavka
- 4,191
- 16
- 33