i have problem using feval function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
>> x(1:7) = randi([4,50],1,7);
d(1:7) = randi([3,5],1,7);
for i = 1 : 7
sum = 0;
w = 1;
sum = sum + w*(x(i) - d(i));
end
f(1) = sum;
for i = 1 : 7
sum = 0;
sum = sum + w*(x(i) - 4);
end
f(2) = sum;
f = f(1) + f(2);
>> a = Particle_Swarm_Optimization (10,2,[4 50;3 5],f,randi(100,50),2,2,2,0.4,0.9,3);
Completed 0 % ...Error using feval
Argument must contain a string or function_handle.
Error in Particle_Swarm_Optimization (line 103)
availability(p,itr)=feval(Food_availability,parameter);
0 commentaires
Réponses (1)
Geoff Hayes
le 19 Déc 2014
Arudrha - according to the documentation for the PSO at the FEX Particle Swarm Optimization, the fourth input parameter must be a function of one variable. Pramit Biswas' example is of a function that accepts an array input as
function f = funfunc(array)
a=array(1);
b=array(2);
f = a+b ;
end
In your code, you are not passing a handle to a function but are instead passing the scalar value f.
0 commentaires
Voir également
Catégories
En savoir plus sur Particle Swarm dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!