I have following Code in Matlab:
function y = myfun(x)
% Set Variables
Svl=1;
B=54.433;
F=4379.250;
T=21.398;
V=53363.500;
% Computing Prefactors with set variables
Zahl1=-B+13.2855-6.10101*Svl;
Zahl2=-F-13938.9+5073.43*Svl;
Zahl3=-V-599882+229920*Svl;
Zahl4=-T-8.2379-0.964978*Svl;
Pl1=2.99983 -0.438557 *Svl;
Pl2=850.573-294663*Svl;
Pl3=31769.1-12055.5*Svl;
Pl4=1.80671 -0.256667 *Svl;
vs1=0.0255558*Svl -0.0498925;
vs2=20.0274 -8.33864*Svl;
vs3=1061.95-415.967*Svl;
vs4=-0.00980451+0.0119915*Svl;
Plvs1=-0.00215169;
Plvs2=-1.20681+0.465007*Svl;
Plvs3=-56.1611+21.7506*Svl;
Plvs4=-0.00162471;
% Equations
y = zeros(4,1);
y(1) = Zahl1+Pl1*x(1)+vs1*x(2)+Plvs1*x(1)*x(2);
y(2) = Zahl2+Pl2*x(1)+vs2*x(2)+Plvs2*x(1)*x(2);
y(3) = Zahl3+Pl3*x(1)+vs3*x(2)+Plvs3*x(1)*x(2);
y(4) = Zahl4+Pl4*x(1)+vs4*x(2)+Plvs4*x(1)*x(2);
I have a set of four nonlinear equations y() and only two unknowns x(1) and x(2). Zahlx, Plx, vsx and Plvsx are known and only prefactors which are computed before in this code.
How do I solve the above set of overdetermined nonlinear equations in Matlab?
I tried it with the least squeres:
x0 = [20,100];
lb = [20,100];
ub = [40,500];
[x,resnorm,res,eflag,output1] = lsqnonlin(@myfun,x0, lb, ub); % Invoke optimizer
x(1)
x(2)
But the result makes no sence.
I get the following result:
Initial point is a local minimum.
Optimization completed because the size of the gradient at the initial point
is less than the default value of the function tolerance.
<stopping criteria details>
%x(1)
ans =
20
%x(2)
ans =
100
But x(1) should be near 40 and x(2) near 500. He computed only the start point.
Any ideas?
I hope somebody can help me. Thank you very much in advance.