MATLAB Answers

Ode45 change of a value in the equations

2 views (last 30 days)
Marco Puglia
Marco Puglia on 30 Oct 2019
Commented: Stephan 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.

  4 Comments

Show 1 older comment
Marco Puglia
Marco Puglia 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 on 30 Oct 2019
365th step means t=365 for you?

Sign in to comment.

Answers (1)

Stephan
Stephan on 30 Oct 2019
Edited: Stephan 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.

  2 Comments

Marco Puglia
Marco Puglia 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
Stephan on 30 Oct 2019
Please share your code so far

Sign in to comment.


Translated by