# implementation of an ODE system, not the expected output

2 views (last 30 days)
Sylvain Bart on 19 Sep 2019
Commented: Sylvain Bart on 20 Sep 2019
Hello,
I don’t get what I would like with my ODE systems and I don’t understand why, if someone could help me it would be great (thank you to any readers)
I have 6 variables input: S DwA DwB Dw TH and K and several constant parameters
Here is my function:
y=[1 0 0 0 0 0]
function dy = deri(t,y,par,cA,cB)
%% Unpack states
S = y(1);
DwA = y(2);
DwB = y(3);
Dw = y(4);
TH =y(5);
K =y(6);
%% Unpack parameters values
kdA = par(1);
mwA = par(2);
bwA = par(3);
hbA = par(4);
kdB = par(5);
mwB = par(6);
bwB = par(7);
hbB = par(8);
hb = max(hbA,hbB);
%% Calculate the model output
dDwA = kdA * (cA - DwA);
dDwB = kdB * (cB - DwB);
dDw=dDwA +dDwB; % Dw(t)= DwA(t) + DwB(t)
% until here I get everything I expect (the expected values) for the three above variables
% here are the issues
dTH=(mwA*(dDwA/dDw)) + (mwB*(dDwB/dDw)); % for TH I don’t get the expected values, and I don’t know why
% at each time point it should be: TH(t)=(mwA*(DwA(t)/Dw(t))) + (mwB*(DwB(t)/Dw(t))), TH should decrease over time
dK=(bwA*(dDwA/dDw)) + (bwB*(dDwB/dDw))
% I have the same issue for K (same equation but with the constants bwA and bwB)
% For the following I don't know as TH and K are not calculate as expected
h = K * max(0,Dw-TH); % calculate h
dS = -(h + hb)* S; %change in survival probability
dy = [dS;dDwA;dDwB;dDw;dTH;dK]; % collect derivatives in one vector
Sylvain
##### 2 CommentsShowHide 1 older comment
Sylvain Bart on 20 Sep 2019
Thank you for your reply, it was useful to know this and I will use it in the futur.

### 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!

Translated by