Bad results of lsqnonlin
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Matt J
2014년 9월 30일
편집: Matt J
2014년 9월 30일
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!