Event function for ODE solver

8 visualizaciones (últimos 30 días)
Kevin Gunawan
Kevin Gunawan el 31 de Oct. de 2011
Editada: Jan el 26 de Jul. de 2017
Hi, I am using ode15s and would like to ask how to use Events function. So basically I need to stop the ODE solver iteration before the given time span, to be exact when the values of y equals to certain values e.g y(i)=0.01 (my y vector stores more than one variable) I have browsed a lot of questions here and all seems suggest the ballode function, but is there anyone who can kindly guide me step by step on how to use it?
Thanks!

Respuestas (2)

Mahmudul Hasan
Mahmudul Hasan el 11 de Oct. de 2013
Its easy. Just set the value = y(i)- 0.01 in event function, please. Like:
[value isterminal direction] = event_function(t,y)
value = y(i)-0.01; isterminal=1; direction = 0;
Hope this helps you a lot.
Thanks Mahmudul

Jan
Jan el 31 de Oct. de 2011
  3 comentarios
Steven Lord
Steven Lord el 26 de Jul. de 2017
There are a couple examples in the documentation.
Jan
Jan el 26 de Jul. de 2017
Editada: Jan el 26 de Jul. de 2017
@Zhenke Xi: Calm down. If you want to ask for an example, simply ask for an example.
Open the first link, search for "For more information, see ODE Event Location" and click on the link (it is and the 2nd last paragraph of "Description").
Alternatively you can ask an internet search engine for "Matlab ode event function example". This requires less exclamation marks.

Iniciar sesión para comentar.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by