My Matlab program has multiple inputs as a struct (in.a, in.b, etc.)
and multiple outputs (out.a, out.b, etc.)
I would like to use the genetic algorithm solver from teh optimization toolbox to find the best input in.a, while all the other inputs are constant. The fitness is one of the outputs, e.g. out.b(2,3).
How do I “tell” the solver this?
Thanks
Daniel
It is not uncommon in programming to have a situation where what is most convenient for your function and what some library call expects of it don’t agree. The normal resolution to such a problem is to write a small layer in between that allows the two to talk; an interface.
From
help ga:So,
gaexpects vector input, scalar output, whereas you have a structure going in and out. You would have to write the following (sub)function:and then the call to
gawill look likewhere
Nis however largein.ashould be.Also have a read about it in Matlab’s own documentation on the subject.