ODE45 specific time point settings
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Eran Sandman
il 10 Giu 2020
Commentato: Star Strider
il 16 Giu 2020
Hello!
I'm trying to stimulate BIG model in different situations (Beta-cells , insulin , glucose).
The following function is very simple. I'm able to change the parameter 's' at t>100.
%%% BIG Model %%%
function yprime = big(t,y)
s=1;
delta=1;
q=1;
if t>100
s=0.2;
end
yprime = zeros(3,1);
yprime(1) = m - s*y(2)*y(1);%dG/d
yprime(2) = (q * y(3) * (y(1))^2) - delta * y(2); %dI/dt
yprime(3) = y(3)*0.01*(y(1)-5);%dB/dt
The second thing that I need to do is to change m=2 at t=90, t=110, t=200 (rest of the time m=1)
The problem is that the ODE is choosing the time points by itself and it skips these specific time point. How can I overcome this?
This is the code that i'm using to solve this.
clear all
clc
[t,y] = ode45(@(t,y) big(t,y) , [0:1:400] ,[5,1/5,1/125]);
subplot(1,3,1)
plot(t,y(:,1))
title('Glucose')
xlabel('Time')
subplot(1,3,2)
plot(t,y(:,2))
title('Insulin')
xlabel('Time')
subplot(1,3,3)
plot(t,y(:,3))
title('Beta-Cells')
xlabel('Time')
0 Commenti
Risposta accettata
Star Strider
il 12 Giu 2020
I verified that this version works, however I do not see any significant change in the integrated results.
These added lines:
tcnd = (((t>=90) & (t<91)) | ((t>=110) & (t<111)) | ((t>=200) & (t<201)));
m = tcnd*2 + (~tcnd)*1;
‘toggle’ ‘m’ between ‘1’ and ‘2’ at the appropriate times. An additional fprintf call allows verification.
The (Slightly Revised) Code —
function yprime = big(t,y)
s=1;
delta=1;
q=1;
if t>100
s=0.2;
end
tcnd = (((t>=90) & (t<91)) | ((t>=110) & (t<111)) | ((t>=200) & (t<201)));
m = tcnd*2 + (~tcnd)*1;
% fprintf('t = %f\t\tm = %d\n',t,m) % Un-Comment To See dm’ At Each Time
yprime = zeros(3,1);
yprime(1) = m - s*y(2)*y(1);%dG/d
yprime(2) = (q * y(3) * (y(1))^2) - delta * y(2); %dI/dt
yprime(3) = y(3)*0.01*(y(1)-5);%dB/dt
end
The Plot —
The only discernable difference are the ‘spikes’.
6 Commenti
Star Strider
il 16 Giu 2020
I’m happy you got it sorted.
I still don’t understand what the problem is with ‘s’. In spite of my experience with metabolic models (specifically glucose regulatory models), I don’t recognise the one you’re using.
Più risposte (2)
darova
il 12 Giu 2020
Try tolerance
function yprime = big(t,y)
m = 1;
if any( abs([90 110 200]-t)<0.5 )
m = 2;
end
0 Commenti
Boxn Hen
il 12 Giu 2020
Do you change m at one point like t=90 ?Ode steps small size ,if the tspan is [0,1] and you set m=1 when t=0,while m=2 in other time,it will be meaningless.What I experience is effective if you change m for a period.
function yprime = big2(t,y)
s=1;
delta=1;
q=1;
m=1;
if t>100
s=0.2;
end
if t>90
m=2;
end
yprime = zeros(3,1);
yprime(1) = m - s*y(2)*y(1);%dG/d
yprime(2) = (q * y(3) * (y(1))^2) - delta * y(2); %dI/dt
yprime(3) = y(3)*0.01*(y(1)-5);%dB/dt
end
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!