Not enough inputs Genetic Algorithm

10 visualizaciones (últimos 30 días)
Renovatio
Renovatio el 27 de Mzo. de 2015
Comentada: wawan ramadhan el 23 de Sept. de 2015
Im trying to find 4(x in this case) variables that minimize my function, I have my function defined as:
function z = my_fun(x, y, t)
z = sum((y-(A + B.*(x(1)-t).^x(2) + C.*(x(1)-t).^x(2)).*cos(x(3).*log(x(1)-t)+x(4))).^2);
y and t are two vectors of the same length which I already have.
When I try to run the algorithm Matlab says: "Not enough input arguments." Anyone has any idea how to solve this? Thanks in advance!!!

Respuesta aceptada

Alan Weiss
Alan Weiss el 27 de Mzo. de 2015
You didn't show us your call to ga, but the way you are supposed to call a function with extra parameters (your y and t) is this:
x = ga(@(x)my_fun(x,y,t),4)
Alan Weiss
MATLAB mathematical toolbox documentation
  2 comentarios
Renovatio
Renovatio el 27 de Mzo. de 2015
Thank you very much!!! that seems to have solved my problem. Do you happen to know how I can do the same within the "gatool" interface?
And is there a way for the GA to ignore the A, B, C variables? As I would like to compute them later in a linear regression when I have the values of the other x variables.
wawan ramadhan
wawan ramadhan el 23 de Sept. de 2015
hi sir I have assignment to use estimation using lppl, can you send me matlab code for lppl with genetic algorithm.

Iniciar sesión para comentar.

Más respuestas (1)

John D'Errico
John D'Errico el 27 de Mzo. de 2015
Most probably, you are trying to use the run button from the editor. You don't use run on functions. Only on scripts. (Really run should be disabled for functions.)
Or maybe you are trying to use this function in some other way. Maybe you just typed in my_fun in the command window with no arguments.

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by