How to write a step function, x(t-tau), within a differential equation
4 views (last 30 days)
Show older comments
I am trying to solve and plot the following system of equations, however I am struggling with plotting the T(t-tau) and E(t-tau) functions in Matlab
I have been trying to use the heaviside function but the resulting graphs are not changing with variance in tau. Any help would be greatly appreciated, thank you!
function final_project_4()
r1 = 0.1; k1 = 0.0001; r2 = 0.03; alpha = 24; k2 = 0.00005; k3 = 0.000024;
u2 = 0.3; gamma = 0.3; c = 3.8; u1 = 0.03; epislon = 0.1; N = 275;
tau = 15;
TSpan = [0 250];
Y0 = [50 780];
options = odeset('RelTol', 1e-10,'AbsTol',[1e-10,1e-10]);
[t,y] = ode45(@model,TSpan,Y0,options);
plot(t,y)
title('tau = 15')
xlabel('time (days)')
ylabel('concentration')
legend('T(t)-cancer cells','E(t)-effector cells')
function res = model(t,y)
T = y(1);
E = y(2);
Ttau = T*heaviside(t-tau) ;
Etau = E*heaviside(t-tau) ;
dTdt = r1*T - k1*T*E;
dEdt = r2*T + alpha - u1*E - k1*T*E + (1-epislon)*k1*Ttau*Etau;
res = [dTdt;dEdt];
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!