# How to get as output the values of a parameter which change over time, but is not a derivative, in a function with an ODE system

2 Ansichten (letzte 30 Tage)
Sylvain Bart am 20 Sep. 2019
Kommentiert: Sylvain Bart am 10 Okt. 2019
Hello everyone,
I have an ODE system like this, with 2 variables D and S:
function dy = deri(t,y,par) %par are a, b, c, d, hb y=[1 0]
dD= a * (c - D);
h = b * max(0,D-d); %h is calculate based on D at each time point
dS = -(h + hb)* S;
dy = [dS;dD]; % collect derivatives in one vector
My question is how to get as output the values of h over time?
I tried to add it as input like a variable and thus as output dy = [dS;dD;h], but it seems the values return are not correct
Sylvain
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Naveen Venkata Krishnan am 10 Okt. 2019
Hello Sylvain,
Can you try this once, after the execution of ode you will be having D(t) , S(t) over the specified tspan. Try calling another function that takes D(t) and gives out h(t) over the same tspan.
%-ode part-----
h = cal_h(D,b,d);
Function:
function H = cal_h(D,b,d)
H = zeros(size(D,1),1);
H = b * max(0,D-d);
end
Am not really sure whether this is what you might be looking for but i hope this helps you a bit.
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Sylvain Bart am 10 Okt. 2019
Cheers,
Sylvain

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by