How can I call a value from another function?
Ältere Kommentare anzeigen
I'm using Genetic Algorithm to solve my minimization problem. My fitness function has a variable that change to achieve my objective and other that is summed from the main function(where there are the constraints). The objective function is:
lanc_unicob=abs(v) +abs(z)
The GA will change variable v in the main function to active the objective. The value z will be changed in the main function according v changed(cause z depends on v). I wanna know how can I call z in the fitness function, 'cause that way above appear the message: "Undefined function or' variable 'z". I don't know how can I call z from the main function.
1 Kommentar
Geoff Hayes
am 16 Aug. 2017
Aline - can you post the complete fitness function (especially signature)? If you nest this function within your main function (see Nested Functions) then the fitness function will have access to z...though I'm not sure how your main function will interact with the GA...
Antworten (0)
Kategorien
Mehr zu Genetic Algorithm finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!