Error "Supplied objective function must return a scalar value."

1 回表示 (過去 30 日間)
ANCY S GEORGE
ANCY S GEORGE 2022 年 6 月 3 日
編集済み: ANCY S GEORGE 2023 年 1 月 30 日
Hi,I am trying to minimize a function,but shows an error,
Error using fmincon (line 641)
Supplied objective function must return a scalar value.
Error in program23 (line 56)
[a,fv] = fmincon(f,X0,[],[],[],[],[3 3],[8 8])
Can someone explain me why? Please help me to correct this code.
Thanks in advance

採用された回答

Torsten
Torsten 2022 年 6 月 3 日
The function you pass to fmincon returns a vector of values, not a scalar.
Maybe you mean
f=@(a) norm(sum(((a(1).*(G(x,:)+m)+a(2).*(G(y,:)+p)+gb*(H(x,:)./(a(1)))+gb*(H(y,:)./(a(2)))))));
or something similar.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by