In an assignment A(I) = B, the number of elements in B and I must be the same.
1 view (last 30 days)
Show older comments
Imad EL KHLIFI
on 6 Jul 2020
Commented: Star Strider
on 9 Jul 2020
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
0 Comments
Accepted Answer
Star Strider
on 6 Jul 2020
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 Comments
More Answers (0)
See Also
Categories
Find more on Particle Swarm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!