How can I call a value from another function?

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 Comment

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...

Sign in to comment.

Answers (0)

Asked:

on 16 Aug 2017

Edited:

on 16 Aug 2017

Community Treasure Hunt

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

Start Hunting!