Clear Filters
Clear Filters

Events function not working properly

5 views (last 30 days)
Matija
Matija on 18 Jan 2016
Hello,
i have been trying to simulate solenoid movement using the upgraded code of "ballode" function. That is why i'll try my best to compare my code with ballode.
The ball in the "ballode" function works as follow: you set the initial hegiht of the ball and then you drop it. When the ball reaches the ground it will bounce off of it. The number of bounces are connected to coefficient of restitution and with height, but in the end (as long as coeff is <1) the ball will stop bouncing and the height will be 0.
My solednoid code is working in similar order, but instead of gravity pulling the ball down, i have magnetic force pulling solenoid core inside. The core can travel a set amount of displacement, before it will hit the wall (casing). This is where the problem lies. My core will bounce off a wall a few times, but after a set ammount of bounces (when the displacement between core and wall is closing to 0) the core will just "jumo over" the maximum set value.
You can see this in the attached picture. The red curve is core displacement, and the red dotted line is the maximum displacement. As you can see, there are a few bounces, but after that the movement of core continues.
I have tried to change "RelTol" in odeset to smaller or higher values, but it did not make a change (it changed the output, but this did not solve my problem). I have tried to make my workaroud for my code, but in the long run, nothing helped me and i still think that this "event" should work.
I hope the problem is cleary explained, if there is any more information you need, please dont hesitate to ask.
Best regards,
Matija
  1 Comment
Nicolas Mira Gebauer
Nicolas Mira Gebauer on 20 Oct 2020
Hi Matija,
I hope you get to see this message many years later. I am having a similar issue... Event function simply doesn't get to detect the event in a proper manner in my code. It just randomly works sometimes, and sometimes the condition isn't triggered.
Did you find the issue?
Best regards,
Nicolas

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!