Error using fzero (line 257)
Function values at interval endpoints must be finite and real.
Error in interphase (line 24)
[z, fval, exitflag, output] = fzero(fun,x0);
function interphase
clear all
format long
yAG=0.179066;
xAL = 7.2;
ky = 0.02919;
kx = 0.767108;
x0=[0 1];
myfun1 = @find_initial_value;
fun1=@(x)myfun1(yAG, x);
[z, fval, exitflag, output] = fzero(fun1,x0);
xhigh = z;
xAstar=xhigh
x0=[xAL xhigh];
myfun = @intersect_equilibrium;
fun=@(x)myfun(yAG, xAL, kx, ky, x);
[z, fval, exitflag, output] = fzero(fun,x0);
xAi=z
yAi=equilibrium(xAi)
function res=equilibrium(x)
res=29.412*x+160.41*x^2;
end
function res = find_initial_value(yAG,x)
res = yAG - equilibrium(x);
end
function res = intersect_equilibrium(yAG, xAL, kx, ky, x)
y = equilibrium(x);
if abs(x-xAL)<1e-12
aa=1;
else
aa=kx/(((1-xAL)-(1-x))/log((1-xAL)/(1-x)));
end
if abs(y-yAG)<1e-12
bb=1;
else
bb=ky/(((1-y)-(1-yAG))/log((1-y)/(1-yAG)));
end
res = y -(yAG + aa/bb*(xAL-x));
end
end