Failure in initial objective function evaluation when I'm solving a linear programming.

1 回表示 (過去 30 日間)
Ksss
Ksss 2021 年 6 月 25 日
コメント済み: Ksss 2021 年 6 月 25 日
I'm solving this question above and my code is below:
This is my coding in first file
function z= myobj01(x)
x= -3*x(1)-4*x(2);
end
And this is my coding in second file
fun= @myobj01;
x0=[0,1];
A=[1 1; 1 2; 0 1];
b=[6;8;3];
Aeq=[]; beq=[];
lb=[0,0]; ub=[];
[x,fval]=fmincon(fun,x0,A,b,Aeq,beq,lb,ub)
The problem is occuring in my second coding
It shows
Output argument "z" (and maybe others) not assigned during call to "myobj01".
Error in fmincon (line 535)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in myobj02 (line 8)
[x,fval]=fmincon(fun,x0,A,b,Aeq,beq,lb,ub)
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.
When I run the second coding.
May I ask, where's the problem?

採用された回答

Stephan
Stephan 2021 年 6 月 25 日
Use:
function z= myobj01(x)
z= -3*x(1)-4*x(2);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSystems of Nonlinear Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by