How could I define a time varying parameter when using ODE45?
Afficher commentaires plus anciens
Hello,
I have a set of ODEs. I am using them to simulate a PK model. The parameter of one of those equations k1 is a time varying variable, when time is within a specific time range, the value of k7 is 100, otherwise is 1. How could I express this in code?
Here are some code I have written:
global k1 k2 k3 k4 k5 k6 k7 tspan;
k1=1;
k2=1;
k3=0.75;
k4=0.108;
k5=1;
k6=3;
for i=1:length(tspan)
if tspan(i)>8 & tspan(i)<24
k7=100;
else
k7 = 1;
end
end
y_0=zeros(1,9);
y_0(1)=(5/1000)/472.54*1000000000;
tspan=0:2:168;
[t,y]=ode45(@derivatives, tspan, y_0);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!