Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Projectile motion with friction in MATLAB (ODE45)

Tags:
  1. Apr 26, 2014 #1
    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 eachother (assuming my equations are correct). Any tips would be greatly appreciated.
     
    Last edited: Apr 26, 2014
  2. jcsd
  3. Apr 26, 2014 #2

    DrClaude

    User Avatar

    Staff: Mentor

    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.
     
  4. Apr 26, 2014 #3
    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}
    $$
     
  5. Apr 26, 2014 #4

    DrClaude

    User Avatar

    Staff: Mentor

    If you take the array y to contain ##(x,y,v_x,v_y)##, then you would write something like
    Code (Text):

    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.)
     
  6. Apr 26, 2014 #5

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Projectile motion with friction in MATLAB (ODE45)
  1. Ode45 help in MATLAB (Replies: 0)

Loading...