In this project, I wrote a matlab code to keep a marker which moves randomly toward a square area, inside the boundary. so the marker moves with a specific speed in a random direction. when the marker reaches to the boundary of the square area, it will first bounce back and then will keep moving to the another random direction. the number of movement and speed of the marker could be chosen by the user.
below there are two short videos that shows this random movement with different speeds and bouncing back of the marker at each boundary of the area.
the second video is the marker with higher movement speed.