how can i work with two variables with genetic algorithm

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.

 采纳的回答

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.

更多回答(0 个)

类别

Community Treasure Hunt

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

Start Hunting!

Translated by