I have differnt coodinate after use fmincon
    조회 수: 2 (최근 30일)
  
       이전 댓글 표시
    
i want to get a coordinate for maximum distance which form is distance =10.361+0.40125.*a-0.34875.*c-0.78375.*a.*c i plot this surface, and i have (1,-1) is the best coordinate and the maximum is 11.8947 but when i do this for fmincon, x0=[0 0]; lowerbound=[-1 -1]; upperbound =[1 1]; function f = distance(x) A=x(1); C=x(2); f= (-1).*(10.361+0.40125.*A-0.34875.*C-0.78375.*A.*C); end function [c ceq]=const(x) A=x(1); C=x(2); c=A+C-2; ceq=[]; end the answer is x=1 y=1 , not a x=1 y=-1!!!!!! plz help me
댓글 수: 5
  Torsten
      
      
 2022년 12월 4일
				Both Matt J and I already changed the settings. 
And the result is as you expect: A = 1 and C = -1.
채택된 답변
  Matt J
      
      
 2022년 12월 4일
        x0=[0 0]; lb=[-1 -1]; ub =-lb;
fmincon(@distance,x0,[1,1],2,[],[],lb,ub)
function f = distance(x)
 A=x(1); C=x(2); f= (-1).*(10.361+0.40125.*A-0.34875.*C-0.78375.*A.*C);
end
댓글 수: 4
참고 항목
카테고리
				Help Center 및 File Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


