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

1 view (last 30 days)
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

Accepted Answer

Star Strider
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

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!