How Does Euler's Method Help Predict the Ball's Landing in Matlab Simulation?

In summary, the conversation discusses the use of Euler's method to determine the location where a ball will strike the ground after being kicked at a high vertical wall. The initial speed and angle of the ball are inputs, as well as the coefficient of restitution and wind force. The code provided shows the use of Euler's method to calculate the trajectory of the ball in two phases - when it hits the wall and when it bounces back. To incorporate the coefficient of restitution, the initial conditions for the second phase must be changed to use the new velocity. The ball will continue to bounce back and forth until it reaches a certain height, so a condition can be added to stop the calculation.
  • #1
TriclesCr
1
0

Homework Statement



Question :

The ball is kicked at a 5m high vertical wall 20m away. The initial speed of the ball is Vm/s and its initial angle of motion is C degrees with the horizontal (both the speed and angle are inputs). When the ball strikes the wall it bounces back with coefficient of restitution e , eventually returning to ground between the wall and the kicker.

The forces acting on the ball are gravity and a wind that acts at right angles to the initial motion of the ball, which generates a force of WN
The ball has diameter of 1 metre and weighs 0.5 kg.
Using Euler’s method,determine the location where the ball strikes the ground.

2. The attempt at a solution

I've never used MATLAB before,so i was looking for a tutorial about euler's method on MATLAB and i found this one : http://www.me.ucsb.edu/~moehlis/APC591/tutorials/tutorial1/node4.html

So i came up with this :

First i divided my work into 2 phases,first phase is when the ball hits the wall,the second one is when the ball bounces back and hit the ground.

%input
m = 0.5; %weighs
g = 9.81; % gravity
w = 1.06; %Wind Force
h = 0.5; %timestep
e = 0.78; % coefficient of restitution
npoints = 41;
%since my stationary point is at the centre of the ball so the distance between the Stationary point to the wall is now 20.5m(41xtimestep(0.5)=20.5)

V = input('Initial Speed ');
C = input('Initial Angle ');
V;
C;

%Equation for the first phase (when ball hits the wall)
% Centre of the ball as a stationary point
% y''(doubledot)=-g
% x''(doubledot)=0
% z''(doubledot)=w/m


%reduce to first oder equations
% let m = y' , s = x' , r = z'


x =zeros(npoints,1);%this initialize the vector y to being all zeros
y =zeros(npoints,1);
z =zeros(npoints,1);
m =zeros(npoints,1);
s =zeros(npoints,1);
r =zeros(npoints,1);

%Initial Condition
x(1) = 0;
y(1) = 0;
z(1) = 0;
m(1) = V*sind(C); %ydot(0)
s(1) = V*cosd(C); %xdot(0)
r(1) = 0; %zdot(0)




for n=1:npoints-1 %loop over the timesteps

m(n+1) = m(n) + h*-g;
y(n+1) = y(n) + h*m(n);

s(n+1) = s(n) + h*0;
X(n+1) = x(n) + h*S(n);

r(n+1) = r(n) + h*(w/m);
z(n+1) = z(n) + h*r(n);

end

plot(x,y,z);

==================================================
is that code right ?
I have not tested yet because i don't have MATLAB on my laptop,i did that one notepad.
If that is right,
How do i calculate the new velocity of the ball when it bounces back using e (coefficient of restitution ) ?
Once I get the new velocity,do I need to do the same step as above with different initial condition ?

Thanks
 
Physics news on Phys.org
  • #2
in advance



Your code looks correct for the first phase of the ball hitting the wall. To calculate the new velocity after the bounce, you will need to use the equation for the coefficient of restitution, which is given by:

Vn = e*Vp

Where Vn is the new velocity and Vp is the previous velocity.

To incorporate this into your code, you will need to change the initial conditions for the second phase to be the final values from the first phase. So, for example, your new initial conditions for the second phase would be:

x(1) = x(npoints);
y(1) = y(npoints);
z(1) = z(npoints);
m(1) = -e*m(npoints); %use the new velocity for y
s(1) = s(npoints); %x velocity remains the same
r(1) = r(npoints); %z velocity remains the same

Then, you can use the same loop as before to calculate the trajectory of the ball for the second phase. Keep in mind that the ball will continue to bounce back and forth until it eventually comes to rest, so you may want to add a condition in your loop to stop the calculation once the ball reaches a certain height (e.g. less than 1 cm).

I hope this helps. Good luck with your calculations!
 

Related to How Does Euler's Method Help Predict the Ball's Landing in Matlab Simulation?

1. What is Euler's Method using Matlab?

Euler's Method is a numerical technique used to solve ordinary differential equations (ODEs). It uses a step-by-step approach to approximate the solutions of ODEs by breaking them down into smaller, simpler calculations. Matlab is a high-level programming language commonly used for scientific and engineering applications, making it a popular tool for implementing Euler's Method.

2. How does Euler's Method work?

Euler's Method works by approximating the solution of an ODE at discrete points using the slope of the tangent line at each point. It starts with an initial value and uses a small step size to calculate the slope at that point. This slope is then used to find the next point on the curve, and the process is repeated until the desired number of points is reached.

3. What are the advantages of using Euler's Method with Matlab?

Using Matlab for Euler's Method offers several advantages, including its ability to handle large and complex systems of ODEs, its built-in functions for numerical calculations, and its user-friendly interface. Matlab also allows for easy visualization of results, making it a powerful tool for solving and analyzing ODEs.

4. Are there any limitations to using Euler's Method with Matlab?

Despite its advantages, Euler's Method does have some limitations when used with Matlab. It is a first-order method, meaning that the error in the approximation increases as the step size decreases. This can result in inaccurate solutions for highly nonlinear systems. Additionally, Matlab may struggle with solving stiff equations, which require a very small step size for accurate results.

5. How can I use Matlab to implement Euler's Method?

To use Matlab for Euler's Method, you will need to define the ODE you want to solve, as well as the initial conditions and step size. You can then use a for loop to iterate through the necessary calculations and store the results in an array. Finally, you can plot the results using Matlab's built-in plotting functions to visualize the solution. There are also many resources available online that provide step-by-step instructions and examples for implementing Euler's Method in Matlab.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
841
  • Engineering and Comp Sci Homework Help
Replies
6
Views
912
  • Engineering and Comp Sci Homework Help
Replies
2
Views
867
  • Engineering and Comp Sci Homework Help
Replies
1
Views
990
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
Back
Top