I've got a problem that is similar to one that I asked previously about the travel for an electron. This task requires me to plot the travel of an electron that enters a circle, with radius 1, with the initial coordinates of (1,0) and exits at (0,1). I'm supposed to use ode45 with the 'Events' options in combination with my function xvel, that (I'm not that sure of) detects when the x-coordinate is 0. I know that the initial velocity for the elextron is 0 along the y-axis, but unknow along the x-axis.
I've decided to write the coordinates in the form [x;y;u;v]. (x,y) = the position of the electron, (u,v)=the velocity of the electron.
function [val,stopp,dir] = xvel(t,xv)
function yprime = particle(t,y)
I've also been given the function yprime from the task. When I plot the figure, it's supposed to look like the figure below (excluding the dotted lines!).
But my figure turns out to look something like this.
I'm not that experienced with 'Events', which is why I'm struggling a lot here. I suspect that the problem lies around that area.
I appreciate any advice/ help I can get!