Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
MATLAB: Is it possible to have two event values whilst using ode45?

Subject: MATLAB: Is it possible to have two event values whilst using ode45?

From: Kitech

Date: 7 Dec, 2012 01:23:09

Message: 1 of 3

I want two limitations to my ode45 calculation of a movement equation: position and time. I have already got the time event to work but I am not sure if and how I can add another event for limiting the position.
I also have many different particles coupled together in one ODE equation and need them to stop individually once they reach a 'roof' as they all travel at different speeds... would I be able to achieve this through events? I have an idea on how I would do this but its very complicated and would probably be very slow...

Any help would be greatly appreciated!

Subject: MATLAB: Is it possible to have two event values whilst using ode45?

From: Torsten

Date: 7 Dec, 2012 11:36:08

Message: 2 of 3

"Kitech" wrote in message <k9rgdt$j2c$1@newscl01ah.mathworks.com>...
> I want two limitations to my ode45 calculation of a movement equation: position and time. I have already got the time event to work but I am not sure if and how I can add another event for limiting the position.
> I also have many different particles coupled together in one ODE equation and need them to stop individually once they reach a 'roof' as they all travel at different speeds... would I be able to achieve this through events? I have an idea on how I would do this but its very complicated and would probably be very slow...
>
> Any help would be greatly appreciated!

Multiplying several event functions makes the solver stop or take an action if at least one of the events occurs. Is it this what you meant with your question ?

Best wishes
Torsten.

Subject: MATLAB: Is it possible to have two event values whilst using ode45?

From: Steven_Lord

Date: 7 Dec, 2012 14:35:53

Message: 3 of 3



"Kitech " <ksm092@hotmail.com> wrote in message
news:k9rgdt$j2c$1@newscl01ah.mathworks.com...
> I want two limitations to my ode45 calculation of a movement equation:
> position and time. I have already got the time event to work but I am not
> sure if and how I can add another event for limiting the position.

Can you say more about your time event? Depending on what you mean, the
event function may not be the most effective way to handle it. For instance,
if you want to solve the system until a specified end time, I would make the
final element of the tspan vector be that specified end time rather than
specifying an arbitrarily long tspan and having the event function cut off
the solver at the specified end time.

> I also have many different particles coupled together in one ODE equation
> and need them to stop individually once they reach a 'roof' as they all
> travel at different speeds... would I be able to achieve this through
> events? I have an idea on how I would do this but its very complicated and
> would probably be very slow...

http://www.mathworks.com/help/matlab/ref/odeset.html#f92-1017470

"value, isterminal, and direction are vectors for which the ith element
corresponds to the ith event function: "

Have your events function return three 2-element vectors where the first
element corresponds to your time event and the second to your position
event.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us