|
I get a problem when I use fsolve to solve a large matrxi equation.
I finished the code,but I can't get the results convergence.It takes a lot steps to run and it can't reach at the desired result after hundred thousand times.
I learned that I need to change the initial value x0 in the function,but how to do it?any trick?
Here is my code:
clc;
x0 = [20 50 30 10 30 30 20 10 10 10 18 39 28 40 18 29 80 42 13 19 45 26 35 11 40 18 10];
options=optimset('Display','iter','MaxFunEvals',10000,'MaxIter',1000,'TolFun',1e-7);
[x,fval] = fsolve(@XijScales,x0,options);
function F = XijScales(x)
X21g11s = [-480.6487 0 0
0 -475.9206 0
0 0 -475.9206];
X21g12s = [8.2006 0 0
0 0 0
0 0 0];
X12g11s = [-487.6124 0 0
0 -475.9206 0
0 0 -475.9206];
Y21g11s = [-0.1953 0.0485 0.0149
0.0485 -0.8096 -0.1342
0.0149 -0.1342 -0.7426];
Y21g12s = [-0.0053 -0.0364 0.0142
0.0456 -0.0000 -0.0000
-0.0095 -0.0000 0.0000];
Y12g11s = [-0.1761 0.0383 0.0103
0.0383 -0.8073 -0.1102
0.0103 -0.1102 -0.7522];
X21gk11s = [x(1) x(2) x(3)
x(4) x(5) x(6)
x(7) x(8) x(9)];
X21gk12s = [x(10) x(11) x(12)
x(13) x(14) x(15)
x(16) x(17) x(18)];
X12gk11s = [x(19) x(20) x(21)
x(22) x(23) x(24)
x(25) x(26) x(27)];
X21c11s = [X21g11s X21gk11s;X21gk11s' diag([475 475 475])];
X21c12s = [X21g12s X21gk12s;X21gk12s' diag([475 475 475])];
X21c21s = X21c12s';
X12c11s = -[X12g11s X12gk11s;X12gk11s' diag([475 475 475])];
Y11s = inv(X21c11s)+inv(X21c11s)*X21c12s*inv(X12c11s-X21c21s*inv(X21c11s)*X21c12s)*X21c21s*inv(X21c11s);
F1 = Y11s(1:3,1:3)-Y21g11s;
Y12s = -inv(X21c11s)*X21c12s*inv(X12c11s-X21c21s*inv(X21c11s)*X21c12s);
F2 = Y12s(1:3,1:3)-Y21g12s;
Y22s = inv(X12c11s-X21c21s*inv(X21c11s)*X21c12s);
F3 = Y22s(1:3,1:3)-Y12g11s;
F = [F1(1,1);
F1(1,2);
F1(1,3);
F1(2,1);
F1(2,2);
F1(2,3);
F1(3,1);
F1(3,2);
F1(3,3);
F2(1,1);
F2(1,2);
F2(1,3);
F2(2,1);
F2(2,2);
F2(2,3);
F2(3,1);
F2(3,2);
F2(3,3);
F3(1,1);
F3(1,2);
F3(1,3);
F3(2,1);
F3(2,2);
F3(2,3);
F3(3,1);
F3(3,2);
F3(3,3);];
|