how can i work with two variables with genetic algorithm

2 views (last 30 days)
I've created a file with a two variable function, but when i call it at my genetic algorithm script or at the optimization tool it didn't work.
The error menssage said i didn't have enough arguments, so I've tried to use the meshgrid to creat a matrix but it didn't work too.

Accepted Answer

Star Strider
Star Strider on 24 Jan 2020
It would be helpful to know what your fitness function is doing.
If there are independent variables, you can combine them as:
x = [invar1(:) invar2(:)]
Then refer to them in your objective function as: ‘x(:,1)’ and ‘x(:,2)’.
To fit two (or more) dependent variables, the objective function must produce a matrix output so they are the same dimensions.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!