MATLAB: Error Message using GA Genetic Algorithm need help!

gagenetic algorithmMATLAB

I am attempting to use a GA toolbox to optimize an input to a set of ODE equations. I am using a base function for the ODE solver, and a second function as the evaluation function for the GA. I have been able to run the ODE function with the evaluation function with no problem, but when I try to use the GA function, I recieve the message below
Error using eval Undefined function 'fhandle' for input arguments of type 'double'.
Error in ga (line 222) eval(e1str);
Error in Untitled (line 3) [w endPop] = ga([0 2],'fhandle',[],Feed,[1e-6 1 1],'maxGenTerm',1,…
Can anyone give me any guidance on what is going wrong or how to troubleshoot this issue? I am not sure where to go with this and I'm new to using this toolbox:
Top Level Script (GA Script) that is giving errors:
Feed =rand(10,1);
fhandle = @HybridomaSolver1;
[w endPop] = ga([0 2],'fhandle',[],Feed,[1e-6 1 1],'maxGenTerm',1,...
'normGeomSelect',[0.08],['arithXover'],[2 0],'nonUnifMutation',[2 1 3]);
Middle Function (Function I am attempting to use as my evaluation function in the GA)
function [mab_output,Feed] =HybridomaSolver1(Feed,options)
global Feed
Feed = rand(10,1);
x0 = [0.79 2E8 25 4 0 0 0];
tspan = [0 10];
%Push feed schedule and initial parameters into ODE
[t,x]=ode45(@hybridoma,tspan,x0);
mab_output = x(end,7)
ODE Function
function dx =hybridoma1(t,x)
global Feed
global F
%Define Variables
%Fermentor working volume (L) = x(1)
%Concentration of viable cells (cells/L) = x(2)
%Concentration of glucose (mM/l) =x(3)
%Concentration of glutamine (mM/l) = x(4)
%Concentration of Lactate (mM/l) = x(5)
%Concentration of Ammonia (mM/l) = x(6)
%Concentration of Monclonal Antibodies (mg/l)= x(7)
%Define parameter values of the kinetic model
umax = 1.09;
kdmax = 0.69;
yxvglc = 1.09E8;
yxvgln = 3.8E8;
mglc = 0.17E-8;
kmglc = 19.0;
kglc = 1.0;
kgln = 0.3;
alpha = 2.57E-8;
ku = 0.02;
beta = 0.35E-8;
kdlac = 0.01;
kdamm = 0.06;
kdgln = 0.02;
ylacglc = 1.8;
yammgln = 0.85;
f=F;
glcin = 25;
glnin = 4;
%Define kinetic expressions
u = umax*(x(3)/(kglc + x(3)))*(x(4)/(kgln + x(4)));
kd = kdmax*(1/(umax-kdlac*x(5)))*(1/(umax-kdamm*x(6)))*(kdgln/(kdgln+x(4)));
qgln = u/(yxvgln);
qglc = u/(yxvglc);
qlac = ylacglc*qglc;
qamm = yammgln*qgln;
alphaprime = (alpha/(ku + u));
qmab = alphaprime*u+beta;
if t < 1
F=Feed(1);
else
if t < 2
F=Feed(2);
else
if t < 3
F=Feed(3);
else
if t < 4
F=Feed(4);
else
if t < 5
F=Feed(5);
else
if t < 6
F=Feed(6);
else if t < 7
F=Feed(7);
else if t < 8
F=Feed(8);
else if t < 9
F=Feed(9);
else if t < 10
F=Feed(10);
end
end
end
end
end
end
end
end
end
end
dx=zeros(7,1);
dx = [f;x(2)*(u-kd)-x(2)*(f/(x(1)))...
;(glcin - x(3))*(f/x(1))-x(2)*qglc...
;(glnin - x(4))*(f/x(1))-x(2)*qgln...
;qlac*x(2) - (f/x(1))*x(5)...
;qamm*x(2) - (f/x(1))*x(6)...
;qmab*x(2) - (f/x(1))*x(7)];
end

Best Answer

Remove the '' from around 'fhandle' in the ga call:
[w endPop] = ga([0 2],fhandle,[],Feed,[1e-6 1 1],'maxGenTerm',1,...
'normGeomSelect',[0.08],['arithXover'],[2 0],'nonUnifMutation',[2 1 3]);