PHYS 220 — HW #3 [Solution]

This assignment is due at the beginning of lecture on Monday, 16 Feb.


In lecture we've shown how an nth-order ode can be recast as a system of n 1st-order ode. In these 4 problems, you'll be translating the ode given into a single line of MATLAB code. I'll give an example first:

For each of the ode below, write both the figurative construction of y = [ ... ], and the literal line of MATLAB code corresponding to dydx = [ ... ]. (In essence, you're writing the function that the function handle deriv will point to.)The solutions below are not unique, since there are many ways to represent both your figurative variable from the physics/mathematics, and another many ways to implement the code in MATLAB. What you see below are reasonable solutions.

  1. In simulating a bicyclist capable of constant power output P, we find dv/dt = F/m, with Fb = P/v & Fdrag = -av - bv². (This is a 1st-order ode problem, so do not assume F = md²x/dt².)
    Figurative: y = v
    MATLAB: dydt = 1/m*( P/v - a*v - b*v^2);

    Note that since this is a scalar problem, the brackets are unnecessary.


  2. A damped, non-linear simple pendulum has an equation of motion d²θ/dt² = -Ω² sin θ - q dθ/dt.
    Figurative:
    y = [
    th
    w
    ]

    MATLAB:
    dydt = [
    y(2)
    -Omega^2*sin(th) - q*y(2)
    ];


  3. For a mass m in free fall without air resistance near the surface of a planet, we find Fx = 0 & Fy = -mg. (Here you do need to recognize that this is a system of 2nd-order ode.)
    Figurative:
    y = [
    y
    vy
    ]

    MATLAB:
    dydt = [
    y(2)
    -g
    ];


  4. In projectile motion, one might find equations of motion for the projectile as Fx = -mbvvx & Fy = -mg -mbvvy. (Here v is the magnitude of the velocity vector and vi are its components.)
    Figurative:
    y = [
    x
    y
    vx
    vy
    ]

    MATLAB:
    vx = y(3);
    vy = y(4);
    magV = sqrt(vx^2 + vy^2);
    dydt = [
    vx
    vy
    -(b*magV*vx)/m
    -g - (b*magV*vy)/m
    ];