Ode45 change of a value in the equations

2 visualizaciones (últimos 30 días)
Marco Puglia
Marco Puglia el 30 de Oct. de 2019
Comentada: Stephan el 30 de Oct. de 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 comentarios
Stephan
Stephan el 30 de Oct. de 2019
365th step means t=365 for you?
Marco Puglia
Marco Puglia el 30 de Oct. de 2019
yes.

Iniciar sesión para comentar.

Respuestas (1)

Stephan
Stephan el 30 de Oct. de 2019
Editada: Stephan el 30 de Oct. de 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 comentarios
Marco Puglia
Marco Puglia el 30 de Oct. de 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 el 30 de Oct. de 2019
Please share your code so far

Iniciar sesión para comentar.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by