This code is to find the optimum(maximum) value of x3 in range of (-8e-4 to 2e-4) by varying kst,x1,x5 and xo)
% Main file
function rest = Scrpt1(t,X,X_opt)
x5=X_opt(1);
kst=X_opt(2);
xo=X_opt(3);
x1=X_opt(4);
x2 = X(1);
x3 = X(2);
%Parameters
if t>=15
x1 = 0;
end
k1 = 6e7;
km1 = 0.20;
km4 = 0.003;
k3 = 2500.00;
k4 = km4/9;
km3 = km1;
LAP=1.5;
% Differential equations
dx2dt = km1*x3 + km3*LAP - k1*x1*x2 + km4*x3 - k4*x2;
dx3dt = k1*x1*x2 - km1*(x3+x5+xo) - k3*x3*kst;
rest = [dx2dt; dx3dt];
end
% Wrapper function
function max_X3=fun(X_opt)
tspan=[0 60];
y0=[9e-13,0];
options = odeset('InitialStep',0.0001,'RelTol',1e-09);
[~,y] = ode15s(@(t,y) Scrpt1(t,y,X_opt), tspan, y0,options);
max_X3=-max(y(:,2));
end
% x5, kst, xo, x1
initial_search_point=[5, 1, 4, 1e-7];
lower_bounds=[4, 0.1, 4, 1e-9];
upper_bounds=[15, 2, 10, 1e-6];
fmincon(@fun,initial_search_point,[],[],[],[],
lower_bounds,upper_bounds)