From: Yu Li on 11 Jun 2010 16:24 Hi, I am trying to solve a nonlinear equation system by fsolve. After a few runs the solve will terminate and give me 2288;message like below: Optimization terminated: relative function value changing by less than max(options.TolFun^2,eps) and sum-of-squares of function values is less than sqrt(options.TolFun). I am posting my code below, hopefully someone can give me some help. global k11 L20 k21 k22 MT xhT xcf; k11 = 4.6e9; L20 = 5.3e11; k21 = 5.3e9; k22 = 3.4e8; m0 = [9.38e-13,1.75e-11]; xhT = 50e-12; xcf = 0; MT = m0(1); xi = [xhT; MT]; options = optimset('Display','iter','Jacobian','on','TolFun',1.0e-32,... 'TolX',1.0e-12) [x,fval,exitflag,output] = fsolve(@myfun, xi,options) myfun is defined as below function [F,J] = myfun(x,k11,L20,k21,k22,MT,xhT,xcf) global k11 L20 k21 k22 MT xhT xcf; F = [x(1) + k11*x(2)*x(1) + L20*k21*x(2)*x(2)*x(1) + 2*L20*k22*k21*x(2)*x(2)*x(1)*x(1) + L20*k22*k21*x(2)*x(2)*x(1)*xcf - xhT; x(2) + L20*x(2)*x(2) + k11*x(2)*(x(1)+xcf) + L20*k21*x(2)*x(2)*(x(1)+xcf) + 2*L20*k22*k21*x(2)*x(2)*(x(1)*x(1) + xcf*xcf + x(1)*xcf)-MT]; J = [(1 + k11*x(2) + L20*k21*x(2)*x(2) + L20*k22*k21*x(2)*x(2)*(4*x(1) + xcf)), k11*x(1) + 2*L20*k21*x(2)*x(1)*x(1) + L20*k22*k21*x(2)*(4*x(1)*x(1) + 2*x(1)*xcf); k11*x(2) + 4*L20*k21*x(2)*x(2) + 2 * L20*k22*k21*x(2)*x(2)*(2*x(1) + xcf), 1 + 2*L20*x(2) + k11*(x(1) + xcf) + 4*L20*k21*x(2)*(x(1) + xcf) + 4*L20*k22*k21*x(2)*(x(1)*x(1) + xcf*xcf + x(1)*xcf)]; Many many thanks.
|
Pages: 1 Prev: mdce server not reachable Next: How do you do this fast? |