필터 지우기
필터 지우기

Optimization using fval function

조회 수: 11 (최근 30일)
Michael Hay
Michael Hay 2021년 3월 6일
댓글: Michael Hay 2021년 3월 6일
I am having trouble getting this code to run. The goal is to minimize the cost of a dumpster while keeping within a certain volume range using lagrange multipliers. My code runs but the error message that comes up is "Failure in initial objective function evaluation. FSOLVE cannot continue.". I am pretture sure lines 9 and 10 are wrong but can someone help me with this?
function F = Dumpster(quad)
L = quad(1);
W = quad(2);
H = quad(3);
X = quad(4);
F = [5*W+6*H-(W*H),5*L+6*H-(H*L),6*L+6*W-(W*L),L*W*H-1056];
test1 = [1,2,3,4];
[w1,fval] = fsolve(@Dumpster,test1);
w1;
fval;
end
  댓글 수: 6
Michael Hay
Michael Hay 2021년 3월 6일
I just pulled fsolve outside of the function and it is giving me the same error message. Do I need to put the fsolve ourside of the script and into the command window?
Michael Hay
Michael Hay 2021년 3월 6일
Just got it all figured out! Had to put a ; after the fsolve into the command prompt in order to suppress it getting the critical points! Thank you for the help

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Control Design in Simulink에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by