首页 文章

求解matlab中确定的非线性方程

提问于
浏览
0

实际上我必须从大概8或9个非线性方程计算3个变量的值(可能更精确) .

我正在使用lsqnonlin和fsolve . 使用lsqnonlin,它表示求解器过早停止(主要是由于迭代值,funEvals和容差),输出远离精确解 . 我试过,但我不知道我应该在什么基础上设置这些参数 .

使用fsolve,它说没有找到解决方案 .

我还使用了LMFnlsq和LMFsolve,但它的输出远远不及确切的解决方案?我也试图改变其他参数,但我无法将这些解决方案带到我想要的值 .

有没有其他方法可以解决这些超定的非线性方程?

My code till now:

x0 = [20 40 275];

eqn = @(x)[((((x(1)-Sat(1,1))^2+(x(2)-Sat(1,2))^2+(x(3)-Sat(1,3))^2))-dis(1)^2);
    ((((x(1)-Sat(2,1))^2+(x(2)-Sat(2,2))^2+(x(3)-Sat(2,3))^2))-dis(2)^2);
    ((((x(1)-Sat(3,1))^2+(x(2)-Sat(3,2))^2+(x(3)-Sat(3,3))^2))- dis(3)^2);    
    ((((x(1)-Sat(4,1))^2+(x(2)-Sat(4,2))^2+(x(3)-Sat(4,3))^2))- dis(4))^2;    
    ((((x(1)-Sat(5,1))^2+(x(2)-Sat(5,2))^2+(x(3)-Sat(5,3))^2))- dis(5))^2;    
    ((((x(1)-Sat(6,1))^2+(x(2)-Sat(6,2))^2+(x(3)-Sat(6,3))^2))- dis(6))^2;    
    ((((x(1)-Sat(7,1))^2+(x(2)-Sat(7,2))^2+(x(3)-Sat(7,3))^2))- dis(7))^2;    
    ((((x(1)-Sat(8,1))^2+(x(2)-Sat(8,2))^2+(x(3)-Sat(8,3))^2))- dis(8))^2;    
    ((((x(1)-Sat(9,1))^2+(x(2)-Sat(9,2))^2+(x(3)-Sat(9,3))^2))- dis(9))^2;    
    ((((x(1)-Sat(10,1))^2+(x(2)-Sat(10,2))^2+(x(3)-Sat(10,3))^2))- dis(10))^2];

lb = [0 0 0];
ub = [100 100 10000];

options = optimoptions('lsqnonlin','MaxFunEvals',3000,'MaxIter',700,'TolFun',1e-18);%,'TolX',1);

x= lsqnonlin(eqn,x0,lb,ub,options)

**Error:**

**Solver stopped prematurely.**

lsqnonlin stopped because it exceeded the iteration limit,
options.MaxIter = 700 (the selected value).


x =   20.349       46.633       9561.5

希望得到一些建议!

提前致谢!

1 回答

  • 0

    我通常明确地模拟这个:

    min w'w
    f_i(x) = w_i
    w is a free variable
    L<=x<=U
    

    事先应该很容易计算出可行(但非最佳)的解决方案 . 如果你能找到更好的"good"初始解决方案 . 然后使用通用NLP求解器(例如 fmincon )并传递初始可行解决方案( xw ) . 最好的方法是使用允许自动区分的建模系统 . 否则,您应该提供正确和精确的渐变(如果需要,可以提供二阶导数) . 另见建议here .

相关问题