Bad results of lsqnonlin
3 views (last 30 days)
Show older comments
Hi everybody, I have to solve a 2 non-linear equations system with bounds(upper and lower) I tried lsqnonlin and sometimes it didn't converge to the right answer and i don't understand why!
***A simplified version of the problem (linear and deterministic):
options=optimset('Display','off','MaxIter',1000,'TolFun',1e-009,'TolX',1e-009);
lb = [0,0]; ub = [13.33,6.66]; x0 = [0;0];
xRes = lsqnonlin(@(x)OptimalStrategy2(x,30,1,10,8),q0,lb,ub,options);
***The defined function is the following:
function y = OptimalStrategy2(x,a,b,c1,c2)
y = [a-b*x(2)-c1-2*b*x(1);
a-b*x(1)-c2-2*b*x(2)];
end
*****by running the code I get xRes = 7.0720 6.6600 which is incorrect I'm supposed to get xRes = 6.6600 6.6600 to have both equations satisfied (i.e a-b*x(2)-c1-2*b*x(1)=0 and a-b*x(1)-c2-2*b*x(2)=0)
I need your help to undertand this point please!
0 Comments
Accepted Answer
Matt J
on 30 Sep 2014
Edited: Matt J
on 30 Sep 2014
I'm supposed to get xRes = 6.6600 6.6600 to have both equations satisfied
By direct inspection, I find that xRes = [6.6600 6.6600] does not satisfy your equations. Neither does xRes = [7.0720 6.6600], but it is better in a least squares sense:
K>> f=@(x) OptimalStrategy2(x,30,1,10,8);
K>> norm(f([6.66,6.66]))
ans =
2.0201
K>> norm(f([ 7.0720 6.6600]))
ans =
1.7978
Incidentally, your problem is linear, so you should probably be using LSQLIN.
1 Comment
More Answers (0)
See Also
Categories
Find more on Gaussian Process Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!