I'm trying to do a SOR method to find the eigenvalue and eigenvector. I need to change the scalar weight w from 1 to 1.99 in increment of 0.01. The goal is to find w that corresponds to the smallest of the lambda values. Really appreciate it.
The code i have right now:
D_dig=diag(diag(D_final));
U = triu(D_final);
L=tril(D_final);
P=(1/w)*D_dig + L;
T = [(w-1)/w]*D_dig + U;
lambda=eig(-L \ T);

 Réponse acceptée

KSSV
KSSV le 27 Avr 2018
Modifié(e) : KSSV le 27 Avr 2018
D_dig=diag(diag(D_final));
U = triu(D_final);
L=tril(D_final);
w = 1:0.01:1.99 ;
N = length(w) ;
iwant = zeros(N,1) ;
for i = 1:N
P=(1/w(i))*D_dig + L;
T = (w(i)-1)/w(i)*D_dig + U;
lambda=eig(-L \ T);
iwant(i) = norm(lambda) ;
end
[val,idx] = min(iwant) ;
w(idx)

6 commentaires

Jiawen Sun
Jiawen Sun le 27 Avr 2018
I get that the cell stores all the lambda vectors at different w. But i still don't know how to find the w that corresponds to the smallest of the infinity norm for each of the lambda vectors.
KSSV
KSSV le 27 Avr 2018
Edited the answer
Jiawen Sun
Jiawen Sun le 27 Avr 2018
i get an error saying the min command is invalid.
KSSV
KSSV le 27 Avr 2018
Show full code you used....
Jiawen Sun
Jiawen Sun le 27 Avr 2018
Modifié(e) : KSSV le 27 Avr 2018
D_dig=diag(diag(D_final));
U = triu(D_final);
L=tril(D_final);
w=1:0.01:1.99;
N=length(w);
ineed = cell(N,1);
for i = 1:N
P=(1/w(i))*D_dig + L;
T = [(w(i)-1)/w(i)]*D_dig + U;
lambda=eig(-L \ T);
ineed{i} = norm(lambda,Inf);
end
[val,idx] = min(ineed) ;
w(idx)
D_dig=diag(diag(D_final));
U = triu(D_final);
L=tril(D_final);
w=1:0.01:1.99;
N=length(w);
ineed = zeros(N,1);
for i = 1:N
P=(1/w(i))*D_dig + L;
T = [(w(i)-1)/w(i)]*D_dig + U;
lambda=eig(-L \ T);
ineed(i) = norm(lambda,Inf);
end
[val,idx] = min(ineed) ;
w(idx)

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by