The complete answer would be like this.
- find ga function. (type "edit ga")
- Duplicate it, to a new function like ga_customized.
edit the new created function like this :
function [x,fval,exitFlag,output,population,scores] = ga_customized(fun,nvars,Aineq,bineq,Aeq,beq,lb,ub,nonlcon,intcon,options,extra_param)
and add this code
fun = @(x) fun(x, extra_param);
also find the code part around line 230 and edit it like this:
if nargin < 12, extra_param = [];
if nargin < 11, options = [];
if nargin < 10, intcon = [];
if nargin < 9, nonlcon = [];
if nargin < 8, ub = [];
if nargin < 7, lb = [];
if nargin <6, beq = [];
if nargin <5, Aeq = [];
if nargin < 4, bineq = [];
if nargin < 3, Aineq = [];
end
end
end
end
end
end
end
end
end
end