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

1 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Particle Swarm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by