- #1
grandpa2390
- 474
- 14
Homework Statement
I'm writing a program to plot the trajectory of a baseball. the formula is given to me by the book, but I'm not sure what it means.
Homework Equations
The Attempt at a Solution
I am given that v_d = 35 m/s and delta = 5 m/s
what is v? as in what does it represent? is it the velocity? is it something else?
I use it in a formula to calculate the drag force.
Matlab:
dragForce = Bm * sqrt(initialVelocityX^2 + initialVelocityY^2)
my entire program so far is this
Matlab:
close all
clear all
clc
%define Variables and Matrices
timeStep = .25
initialPositionX = 0
initialPositionY = 0
initialVelocity = 110*0.44704 %mph to m/s
positionX = zeros(1,50);
positionY = zeros(1,50);
positionX(1) = initialPositionX;
positionY(1) = initialPositionY;
theta = 35 * 0.0174533 %degrees to radians
initialVelocityX = initialVelocity * cos(theta)
initialVelocityY = initialVelocity * sin(theta)
vd = 35 %m/s
delta = 5 %m/s
Bm = .0039 + (.0058)/(1+exp((initialVelocity-vd)/delta)) %B2/m
for i = 2:1000
positionX(i) = positionX(i-1) + initialVelocityX * timeStep
positionY(i) = positionY(i-1) + initialVelocityY * timeStep
dragForce = Bm * sqrt(initialVelocityX^2 + initialVelocityY^2)
initialVelocityY = initialVelocityY - (9.8 * timeStep) - (dragForce * initialVelocityY * timeStep)
initialVelocityX = initialVelocityX - (dragForce * initialVelocityX * timeStep)
%initialVelocity = sqrt(initialVelocityX^2 + initialVelocityY^2)
%Bm = .0039 + (.0058)/(1+exp((initialVelocity-vd)/delta))
if positionY(i) <= 0
break
end
end
%a = -positionY(i) / positionY(i-1)
%positionX(i) = (positionX(i) + (a * positionX(i-1))) / (1 + a)
%positionY(i) = 0
%%Plots
figure(1)
hold on
box on
plot(positionX,positionY,'-k')
set(gca,'Xtick',linspace(0,150,4),'fontsize',18,'Ytick',linspace(0,50,6))
set(gcf,'Color','w');
set(gcf,'Resize','on');
ylim([0 30])
xlim([0 150])
hold off
You'll notice the line of code right before the For loop is what I am speaking of. You can also see in my for loop to lines of code commented out. Not knowing what v is, I thought maybe it is the current velocity and that perhaps Bm and then the drag force should change as the velocity changed. It brought my plot closer to where it ought to be (a peak at x= 70 and y=30 and a landing point at about x=120)
But since it didn't solve the problem, I commented it out and came here hoping for a better understanding of what that formula is asking. because in the cannonball program I just did, Bm was given as a constant. Of course air density wasn't included (as the book says it is in this function) and I think the cannonball was smooth (which a baseball is not).
so maybe I am kind of correct and it should change with velocity. The book does have chart showing the change in drag coefficient vs velocity for rough, smooth, and normal baseball.
I don't know. Is that v the current velocity. should Bm be recalculated with every change in velocity? Did I make dumb typos that have resulted in my program breaking that only fresh eyes can spot? :)