MATLAB Problem. How to design matrix from eigenvalues

11 visualizaciones (últimos 30 días)
Panos Kerezoudis
Panos Kerezoudis el 23 de En. de 2023
Editada: Matt J el 24 de En. de 2023
This is a previously posted problem that I am working on but I can't find any solutions online. Here is the description:
Write a function that takes one input argument n and outputs a (n x n) square matrix A with the following properties:
  • A has an eigenvalue of 3
  • all elements of A differ more than .5 from each other
Here is what I have tried so far. I am having difficulty with setting up the specific eigenvalue.
function A = matrix_design(n)
A=randn(n); % set up the matrix
[V,D]=eig(A) % use built-in function for eigendecomposition
abs(A-A.')>0.5 % specify elements of A to differ by 0.5
end
disp(A)
  2 comentarios
Torsten
Torsten el 23 de En. de 2023
I don't understand how the code could lead to a solution of the problem.
Walter Roberson
Walter Roberson el 23 de En. de 2023
Is it possible at all?
d = sym(2)/3
d = 
syms c
M = [c+0*d, c+1*d, c+2*d
c+3*d, c+4*d, c+5*d
c+7*d, c+9*d, c+8*d]
M = 
[V,D] = eig(M);
c0 = solve(D(1)==3, c)
c0 = 
Mnum = double(subs(M, c, c0))
Mnum = 3×3
-2.6566 -1.9899 -1.3232 -0.6566 0.0101 0.6768 2.0101 3.3434 2.6768
eig(Mnum)
ans = 3×1
-2.6320 -0.3377 3.0000
... I guess so, at least for the 3 x 3 case -- and assuming that "A has an eigenvalue of 3" means that at least one of the eigenvalues of the matrix is 3

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 23 de En. de 2023
Editada: Matt J el 24 de En. de 2023
mindist=@(A) min(sqrt(pdist(real(A(:))).^2+pdist(imag(A(:))).^2));
n=5;
Q=rand(n); Q(1)=0;
Q=(1-eye(n)).*Q*0.5/mindist(Q);
r=max(min(sum(Q,2)),0.5);
Q=diag((1:n)*2*r)-Q;
emin=min(eig(Q));
A=Q+speye(n)*(3-emin);
%%CHECK%%%
min(eig(A))
ans = 3.0000
mindist(A)
ans = 0.5000

Más respuestas (1)

Matt J
Matt J el 23 de En. de 2023
Editada: Matt J el 23 de En. de 2023
mindist=@(A) min(sqrt(pdist(real(A(:))).^2+pdist(imag(A(:))).^2));
n=5;
P=rand(n);
D=diag(rand(1,n));
A=P*D/P;
A=A/mindist(A)*0.5;
e=eig(A);
A=A+(3-e(1))*speye(n);
%%Check
mindist(A)
ans = 0.5000
eig(A)
ans = 5×1
3.0000 16.7245 25.2124 29.3054 28.3224

Community Treasure Hunt

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

Start Hunting!

Translated by