ODE45 specific time point settings
Show older comments
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')
Accepted Answer
More Answers (2)
darova
on 12 Jun 2020
Try tolerance
function yprime = big(t,y)
m = 1;
if any( abs([90 110 200]-t)<0.5 )
m = 2;
end
Boxn Hen
on 12 Jun 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

Categories
Find more on Assembly 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!
