Trying to find a minimum value
이전 댓글 표시
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)
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!