In an assignment A(I) = B, the number of elements in B and I must be the same.

1 回表示 (過去 30 日間)
Imad EL KHLIFI
Imad EL KHLIFI 2020 年 7 月 6 日
コメント済み: Star Strider 2020 年 7 月 9 日
Hi,
I am facing a problem with this code:
function [ o ] = ObjectiveFunction ( x, y )
y = [-0,031942757 -0,026181615 -0,021657012 -0,028138069 -0,031475741 -0,053880145 -0,04067255 -0,047216032 -0,043596933 -0,052348757 -0,031803935 -0,040889039 -0,066800182 -0,048539537 -0,034113994 -0,048530382 -0,061684828 -0,072503704];
x<=0.1;
o = y*sum(x); % Sphere test function
end

採用された回答

Star Strider
Star Strider 2020 年 7 月 6 日
By defining ‘y’ in ‘ObjectiveFunction’, you are overwriting whatever you pass to it as ‘y’ as an argument.
Also:
x<=0.1;
may produce a logical vector (denoted as ‘ans’ since it is not assigned to anything specifically), however it apparently is never used anywhere else.
What do you want to do in your function?
  8 件のコメント
Imad EL KHLIFI
Imad EL KHLIFI 2020 年 7 月 9 日
Thank you Star Strider
Star Strider
Star Strider 2020 年 7 月 9 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle Swarm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by