Borrar filtros
Borrar filtros

Changing constant with timespan in ode45 solver

1 visualización (últimos 30 días)
Koren Murphy
Koren Murphy el 15 de Oct. de 2020
Comentada: Bhanu Pratap Akherya el 18 de Ag. de 2021
I am writing a code that solves a set of equations from ode45. However, I have a constant that changes in the equations at every time point. E.g.
dA = J(1)*x;
dB = J(5)*x;
So at t = 0, x =0 but at t = 1, x =0.25 etc. The solutions are then used as initial values for the next ode solver loop etc. How can I implement this so the ode can solve with this in mind?
I have tried for loops but still no luck.

Respuesta aceptada

Alan Stevens
Alan Stevens el 15 de Oct. de 2020
Make x a function of t and call it from the function defining the rate equations ode45 is calling..
  15 comentarios
Alan Stevens
Alan Stevens el 18 de Ag. de 2021
You should make this a completely separate thread, in which you also upload the coding you have implemented so far.
Bhanu Pratap Akherya
Bhanu Pratap Akherya el 18 de Ag. de 2021
Thanks for the reply alan, I have posted the question can you please help? Here is the link to the question: https://in.mathworks.com/matlabcentral/answers/1436182-changing-values-of-rhs-with-each-time-step-in-ode

Iniciar sesión para comentar.

Más respuestas (1)

Ameer Hamza
Ameer Hamza el 15 de Oct. de 2020
Editada: Ameer Hamza el 15 de Oct. de 2020
See this example on the documentation page of ode45(): https://www.mathworks.com/help/matlab/ref/ode45.html#bu3l43b. It shows how to deal with time-varying parameters.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by