how to stop ode45 when one of states reach certain value

Technical Source
1 min readOct 23, 2023

--

[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)

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

Opt = odeset(‘Events’, @myEvent);
[T, Y] = ode45(@YourFun, T, Y0, Opt);

function [value, isterminal, direction] = myEvent(T, Y)
value = (Y(3) == 0.1);
isterminal = 1; % Stop the integration
direction = 0;

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet