In this code, I am trying to find the minimum value of rho_Tw, and find the associated w value with it (so basically trying to find the x value associated with the minimum y value). However, whenever I run the following code, I get 0. Any corrections would be greatly appreciated.
AA = [2 0 -2 0 0 0 0 0 0 0;
0 2 0 -2 0 0 0 0 0 0;
0 -1 7 -2 -3 0 0 0 0 0;
0 0 0 1 -1 0 0 0 0 0;
0 0 0 0 4 0 0 -2 0 0;
0 0 0 0 0 1 0 0 0 -1;
-2 0 0 0 0 0 2 0 0 0;
0 0 -4 0 0 -1 0 8 -3 0;
0 0 0 0 0 -2 0 0 7 -4;
0 0 0 0 0 0 -3 0 0 4];
L = -tril(AA, -1);
U = -triu(AA, 1);
D = diag(AA);
DD = diag(D);
Tj=inv(DD)*(L+U);
rho_Tj=max(abs(eig(Tj)));
for w = 0:0.0005:2
wb=0;
rho_min=0;
Tw=inv(DD-w*L)*(((1-w)*DD)+(w*U));
rho_Tw=max(abs(eig(Tw)))
scatter(w, rho_Tw)
hold on
if w == 0
rho_min = rho_Tw;
wb = w;
end
if rho_Tw < rho_min
rho_min = rho_Tw;
wb=w;
end
end
disp(wb)
Best Answer