how to stop ode45 when one of states reach certain value
Mostra commenti meno recenti
[x_dot] =derivative(t, x)
x is states [x(1).....x(4)] I need to stop the integration when x(3) reaches 0.1 when the integration stop record (t)
Risposta accettata
Più risposte (2)
Walter Roberson
il 4 Mag 2016
Modificato: Walter Roberson
il 13 Set 2017
0 voti
You need to add an event function. See http://www.mathworks.com/help/matlab/ref/odeset.html#input_argument_d0e709348
1 Commento
Mohamed Aburakhis
il 4 Mag 2016
Gustavo Lunardon
il 17 Ago 2020
0 voti
This is confusing. In matlab help it says: An event occurs when value(i) is equal to zero. All answers in this post make it value = 1 for the event to happen. Are the answers outdated somehow?
1 Commento
Walter Roberson
il 19 Ago 2020
This is a valid concern.
value = (X(8) == 0.05 ) and (Y(3) == 0.1) would happen rarely, when the values were bit-for-bit identical to the representation of 0.05 and 0.1 . One bit different in the representation and the condition will not fire. Better is to write x(8) - 0.05 or 0.05 - x(8), and Y(3)-0.1 or 0.1-Y(3) -- zero crossings can be detected for those.
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!