function dx=m1(t,x)
dx(1)=(l0*x(1))/(1+(l0*x(1))
endfunction
function dx=m2(t,x)
dx(1)=(l0*x(1))/[1+(l0*(x(1)+x(2))]
dx(2)=(k2*x(1)*x(1))-k1*x(2)
endfunction
t0=15;
function f(t,t0)
if (t < t0)
{
return m1(t)
}
else
{
return m2(t)
}
end
endfunction
x=ode(x0, t0, t, f);
In the above code, I am defining two functions m1 and m2 and on the basis of a time point, say, t0, I am returning either of the functions. However, the error is showing undefined variable:x. Is it because I am using x(1) in both the functions?
x is basically a vector containing x(1) in the first function m1, and [x(1);x(2)] in m2.
P.S.- all the required value of the constants including the initial values are given.