In an assignment A(I) = B, the number of elements in B and I must be the same.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Imad EL KHLIFI
el 6 de Jul. de 2020
Comentada: Star Strider
el 9 de Jul. de 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 comentarios
Respuesta aceptada
Star Strider
el 6 de Jul. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Particle Swarm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!