## Ode45 change of a value in the equations

### Marco Puglia (view profile)

on 30 Oct 2019
Latest activity Commented on by Stephan

### Stephan (view profile)

on 30 Oct 2019
Hi everybody, I'm new at matlab, and I have a problem with Ode45: This is my system of equations to solve:
[tout,yout] = ode45(@(t,y) EQS(y,m,T,FN,P,D,gamma,tau), ...
[0:number_of_steps],...
initial_condition)
dPdt = + m .* T .* FN .* P - gamma .* P
dNdt = - m .* T .* FN .* P + tau .* D
dDdt = + gamma .* P - tau .* D
Ode45 works perfectly for this system but I need to change the parameter T (a vector) after a certain number of steps. How can I do that? I have tried to place loops and statemetns into the function "EQS" but Ode doesn't care about them.

Show 1 older comment
Marco Puglia

### Marco Puglia (view profile)

on 30 Oct 2019
Just once. T has to change from a gaussian with center in 15, to a gaussian with center in 20 after the 365th step.
Stephan

### Stephan (view profile)

on 30 Oct 2019
365th step means t=365 for you?
Marco Puglia

on 30 Oct 2019
yes.

### Stephan (view profile)

on 30 Oct 2019
Edited by Stephan

### Stephan (view profile)

on 30 Oct 2019

Do 2 calls of ode45. The first from tspan=[0 365]. Then use the final result from this as initial condition for the second call with the changed T.

Marco Puglia

### Marco Puglia (view profile)

on 30 Oct 2019
I can't. Yes, it is feasible in that way, but after this initial code, I have to build something with a T that varies periodically from a value to another.
Stephan

on 30 Oct 2019