Challenge

Week 3 - Solving second order ODEs

The code follows as following

  • Initialization of the vatiable
    • b
    • g
    • l
    • m
  • Initializing Initial Conditions - at initial posiotion theta = 0 velocity is 3
  • Degining 500 timesteps between 0 to 20 sec
  • Solving the ODE usingg ode45
    • Output
      • time
      • results - comlumn vector of position and velocity at every yime step
    • Input
      • t & theta
      • function that provides the differential equation ide_func
        • Inputs
          • time
          • theta
          • b
          • g
          • l
          • m
        • Function - defines the structure of theta 1 and 2
        • Output - A column vector that has theta 1 and theta 2
      • Time steps
      • Initial Condition
  • Creating Animation
    • Initializing the origin
    • frame count
    • For Loop to calculate the pendulum's position at every time step
      • x2=l x sin(theta)
      • y2=l x cos(theta)
      • plotting the line between the origin (0,0) ans (x2,y2)
      • plotting the marker '--o' for each (x2,y2)
      • Storing Frames
      • updating the frame count
      • holding off the plots for next plot
    • Creating the video File
    • openning it and writing frames within it
    • saving it
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.