Projectile motion with friction in MATLAB (ODE45)

In summary: You could use a function to update the value of y, or you could use a loop to keep track of the current value of y and calculate the new value each time through the loop. In either case, you would need to account for the change in y when v changes. In summary, you are working on a project to plot the motion of a projectile with air resistance. The air resistance can be assumed to be proportional to the velocity squared. You have derived the equations of motion as follows: \vec{r}=\left(v_{0}tcos\theta-\frac{1}{2}kvv_{x}e^{-y/y_{0}}
  • #1
cwrn
15
0
I'm working on a little project where I want to plot the motion of a projectile with air resistance. The air resistance can be assumed to be proportional to the velocity squared.

[itex]F_{f}=-Bv^{2}[/itex]

[itex]F_{f,x}=F_{f}\frac{v_{x}}{v}, \ \ F_{f,y}=F_{f}\frac{v_{y}}{v}[/itex]

where B depends on the height, y above the ground

[itex]B(y) = B_{0}e^{-y/y_{0}}[/itex]

Given

[itex]k = \frac{B_{0}}{m}=4\cdot 10^{-5} \ m^{-1}, \ y_{0} = 1\cdot 10^4 \ m, \ v_{0} = 700 \ m/s[/itex]

I have derived the equations of motion as following:

[itex]\vec{r}=\left(v_{0}tcos\theta-\frac{1}{2}kvv_{x}e^{-y/y_{0}}\cdot t^2\right)\hat{i}+\left(v_{0}tcos\theta+\frac{1}{2}\left[\vec{g}-kvv_{y}e^{-y/y_{0}}\right] t^2\right)\hat{j}[/itex]

[itex]\vec{v}=\left(v_{0}cos\theta-kvv_{x}e^{-y/y_{0}}\cdot t\right)\hat{i}+\left(v_{0}sin\theta+\left [\vec{g}-kvv_{y}e^{-y/y_{0}}\right]t\right)\hat{j}[/itex]

[itex]\vec{a}=\left(-kvv_{x}e^{-y/y_{0}}\right)\hat{i}+\left(\vec{g}-kvv_{y}e^{-y/y_{0}}\right)\hat{j}[/itex]

I'm having trouble defining a function I can use with ode45 since there are several variables depending on each other (assuming my equations are correct). Any tips would be greatly appreciated.
 
Last edited:
Physics news on Phys.org
  • #2
I haven't checked if the equations are correct, but they are not differential equations!

What you need for ode45 is something like
$$
\begin{align}
\frac{dx}{dt} &= v_x \\
\frac{dy}{dt} &= v_y \\
\frac{dv_x}{dt} &= a_x \\
\frac{dv_y}{dt} &= a_y
\end{align}
$$
where you replace ##a_x## and ##a_y## by the proper expressions involving the forces.
 
  • #3
DrClaude said:
I haven't checked if the equations are correct, but they are not differential equations!

What you need for ode45 is something like
$$
\begin{align}
\frac{dx}{dt} &= v_x \\
\frac{dy}{dt} &= v_y \\
\frac{dv_x}{dt} &= a_x \\
\frac{dv_y}{dt} &= a_y
\end{align}
$$
where you replace ##a_x## and ##a_y## by the proper expressions involving the forces.

Yes, I'm aware of this. Solving this with ode45 should yield the x and y vectors that I want to plot. I'm just not sure how to define the function itself since it depends on B which in turn depends on y.
$$
\begin{align}
B(y) = B_{0}e^{-y/y_{0}}
\end{align}
$$
 
  • #4
If you take the array y to contain ##(x,y,v_x,v_y)##, then you would write something like
Code:
function dy = projectile(t,y)
B0 = 1;
y0 = 123;

dy = zeros(4,1);    % a column vector
dy(1) = y(3);
dy(2) = y(4);
dy(3) = B0 * exp(-y(2)/y0) * y(3);
dy(4) = B0 * exp(-y(2)/y0) * y(4);
(Note that the code doesn't correspond to your problem.)
 
  • #5
cwrn said:
Yes, I'm aware of this. Solving this with ode45 should yield the x and y vectors that I want to plot. I'm just not sure how to define the function itself since it depends on B which in turn depends on y.
$$
\begin{align}
B(y) = B_{0}e^{-y/y_{0}}
\end{align}
$$

You start off your calculations with a known position for the projectile, which means you are going to know an initial value for y. As the calculation progresses, then the values of y will need to be updated depending on your independent variable, which I assume would be time.
 

1. What is projectile motion with friction?

Projectile motion with friction is a type of motion where an object is projected into the air and experiences the effects of both gravity and friction. This type of motion is commonly seen in sports, such as throwing a ball, and can be modeled using mathematical equations.

2. How is projectile motion with friction modeled in MATLAB?

Projectile motion with friction can be modeled in MATLAB using the ODE45 function, which is a numerical method for solving ordinary differential equations. This function allows you to input the initial conditions and parameters of the motion, such as initial velocity and friction coefficient, and calculates the trajectory of the object.

3. What are the benefits of using MATLAB for modeling projectile motion with friction?

MATLAB is a powerful software tool that allows for efficient and accurate modeling of complex systems, such as projectile motion with friction. It has built-in functions and tools that make it easy to input equations, visualize results, and make adjustments to parameters. Additionally, MATLAB allows for easy integration with other programs and tools, making it a versatile choice for scientific research.

4. Can you provide an example of using ODE45 in MATLAB for projectile motion with friction?

Yes, an example of using ODE45 in MATLAB for projectile motion with friction would involve defining the initial conditions and parameters, such as initial velocity and friction coefficient, and using the ODE45 function to calculate the trajectory of the object. The resulting output would be a graph of the object's position over time.

5. How accurate is the modeling of projectile motion with friction in MATLAB?

The accuracy of the modeling in MATLAB depends on the accuracy of the initial conditions and parameters that are input, as well as the numerical methods used in the ODE45 function. With proper input and adjustments, MATLAB can provide highly accurate results for projectile motion with friction. However, it is always important to verify the results with real-world experiments to ensure accuracy.

Similar threads

  • Introductory Physics Homework Help
Replies
1
Views
184
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • Introductory Physics Homework Help
Replies
7
Views
190
  • Calculus and Beyond Homework Help
Replies
20
Views
442
  • Calculus and Beyond Homework Help
Replies
2
Views
160
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
982
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
Replies
2
Views
747
  • Calculus and Beyond Homework Help
Replies
1
Views
452
  • Introductory Physics Homework Help
Replies
11
Views
213
Back
Top