How Does Spin Affect a Soccer Ball's Trajectory in Matlab Simulation?

  • Context: MATLAB 
  • Thread starter Thread starter em504346
  • Start date Start date
  • Tags Tags
    Matlab Program
Click For Summary
SUMMARY

This discussion focuses on simulating the trajectory of a soccer ball in MATLAB, specifically analyzing the effects of spin on its path. The provided MATLAB code calculates the ball's motion using parameters such as drag coefficient (Cd), spin coefficient (Cs), air density (p), radius (r), and mass (m). Users encountered issues with the program not returning spin values as expected, prompting suggestions to simplify the stopping conditions and improve code efficiency. The discussion emphasizes the importance of clear output and meaningful computations in simulations.

PREREQUISITES
  • Understanding of MATLAB programming and syntax
  • Familiarity with physics concepts such as forces, drag, and spin
  • Knowledge of numerical methods for simulating motion
  • Basic understanding of 3D plotting in MATLAB
NEXT STEPS
  • Explore MATLAB's fprintf function for formatted output
  • Learn about simplifying stopping conditions in simulations
  • Investigate numerical integration techniques for motion simulation
  • Study the impact of different spin coefficients on projectile motion
USEFUL FOR

This discussion is beneficial for physics students, MATLAB programmers, and sports scientists interested in modeling and analyzing the dynamics of soccer ball trajectories under various conditions.

em504346
Messages
1
Reaction score
0
clear;
Cd = .5;
Cs = .5;
p = 1.2; %Air density
r = .11303; %radius
m = .4536; %mass


x(1) = 0; %initial position
y(1) = 0;
z(1) = 0;

wx = 0; %initial angular velocity for x

wy = 0;

vx(1) = 14.95; %intial velocity for x
vy(1) = 14.5;
vz(1) = 7.9;
k = -300;
g = 9.81; %gravity
dt = .001;
t = 20;
n = t/dt;

for j = 1:n
wz = j;
for i = 1:n

u = sqrt((vx(i))^2+(vy(i))^2+(vz(i))^2); %v for all components

ax = (-((Cd*p*pi*r^2)*u*vx(i))/(2*m) - ((Cs*p*pi*r^3*(vz(i)*wy-wz*vy(i)))/(2*m)));
ay = (-((Cd*p*pi*r^2)*u*vy(i))/(2*m) - ((Cs*p*pi*r^3*(wz*vx(i)))/(2*m)));
az = ((-g)-((Cd*p*pi*r^2)*u*vz(i))/(2*m) + ((Cs*p*pi*r^3*(-wy*vx(i)))/(2*m)));

Fx = ax*m; %Force for x-component
Fy = ay*m;
Fz = az*m;

vx(i+1) = vx(i) + ((Fx/m)*dt); %Final velocity for x-component
vy(i+1) = vy(i) + ((Fy/m)*dt);
vz(i+1) = vz(i) + ((Fz/m)*dt);

x(i+1) = x(i) + vx(i+1)*dt;
y(i+1) = y(i) + vy(i+1)*dt;
z(i+1) = z(i) + vz(i+1)*dt;

if(x(i+1)>(11.531+ .1524))

break
end

if((y(i+1)>10.9564)&(y(i+1)<11.531))&((z(i+1)>1.8288)&(z(i+1)<2.3254))&((x(i+1)>11.531)&(x(i+1)<(11.531+.1524)))
fprintf('q')
break

end

end
fprintf('number %g',wz);
end

plot3(x,y,z)
grid on

This is a program that shows the force and spin it would take to put a soccer ball into the upper right hand corner of the goal. I found the values I wanted with no spin included. NOw I want to run the program and let it give me back the values of different spin it would take to get to this point of choice. I'm holding everything else constant including one or the other spin components wz or wy and just letting one of them very, wz or wy. I want the the program to tell me the values of spin, but IT IS NOT. Do I need to set the fprintf somewhere specific or what? Any suggestions would be great

THANKS
 
Last edited:
Physics news on Phys.org
Fx = ax*m; %Force for x-component
Fy = ay*m;
Fz = az*m;

vx(i+1) = vx(i) + ((Fx/m)*dt); %Final velocity for x-component
vy(i+1) = vy(i) + ((Fy/m)*dt);
vz(i+1) = vz(i) + ((Fz/m)*dt);

Why to you multiply by m in one line then divide by it in the next? Why do unnecessary computations?

Try a smaller step. put a loop counter in, stop after a set number of time steps.

Are your numbers meaningful? It really seems like you have a complicated stopping condition, figure out something a bit simpler.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 11 ·
Replies
11
Views
5K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K