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
- Inputs
- Time steps
- Initial Condition
- Output
- 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