Not enough inputs Genetic Algorithm
1 次查看(过去 30 天)
显示 更早的评论
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!!!
0 个评论
采纳的回答
Alan Weiss
2015-3-27
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 个评论
wawan ramadhan
2015-9-23
hi sir I have assignment to use estimation using lppl, can you send me matlab code for lppl with genetic algorithm.
更多回答(1 个)
John D'Errico
2015-3-27
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!