Not enough input arguments
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
Hi, I try to create a genetic algorithm model and i try to create a fitness function to calculate fitness of every child. However, Matlab gives a function input error.
Here is the code that I wrote so far,
_
function [ fitness ] = calcfitness( breedingpop, nbreeding, penalty )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
for i=1:nbreeding
fitness = (breedingpop(nbreeding).penalty - breedingpop(i).penalty) / (breedingpop(nbreeding).penalty - breedingpop(1).penaltybreedingpop)
end
i know "penalty" is not the correct way to add as an argument. Does anyone have any idea how I could add penalty as an argument. Thanks
Respuestas (1)
Azzi Abdelmalek
el 21 de Jun. de 2013
Editada: Azzi Abdelmalek
el 21 de Jun. de 2013
function [ fitness ] = calcfitness( breedingpop, nbreeding, penalty )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
for i=1:nbreeding
fitness = (breedingpop(nbreeding).(penalty) - breedingpop(i).penalty) / (breedingpop(nbreeding).(penalty) - breedingpop(1).penaltybreedingpop)
end
penalty should be a strindg
6 comentarios
tevzia
el 21 de Jun. de 2013
Azzi Abdelmalek
el 21 de Jun. de 2013
Did you read my answer?
use
breedingpop(nbreeding).(penalty) % instead of
breedingpop(nbreeding).penalty
tevzia
el 21 de Jun. de 2013
Azzi Abdelmalek
el 21 de Jun. de 2013
How did you call your function?
tevzia
el 21 de Jun. de 2013
Azzi Abdelmalek
el 21 de Jun. de 2013
penalty should be a string
childfitness = calcfitness(breedingpop, nbreeding, 'penalty' )
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!