Week 3 - Solving second order ODEs
Newton's second low is given by:
F = m*a
where:
F is force in N
m is the mass of the object in kg
a is the acceleration due to gravity in m/s^2
Ordinery Differential Equation-ODE
Differential equation is used to relates the one or more functions and its derivatives.
here we going to relate the two functions lsuch as time and angular displacement.
t and theta are the function here.
Here pednulum acts like a spring, When apply the force on the pendulum ball will create the to and fro angular motion.
one end of the pendulum is fixed and another end is free to rotate.
ODE here used to study the movement of pendulum.

d^2theta/dt^2 + b/m*dtheta/dt + g/L*sintheta = 0
Where:
g = Acceleration due to gravity in m/s2
L = length of the pendulum in m
m = mass of the ball attached to the pedulum rod in kg
b=damping coefficient
Given set of data:
L=1 metre
m=1 kg
b=0.05
g=9.81 m/s2
First need to brake the second order ODE into two first order ODEs
let me take
theta = theta1
dtheta/dt = theta2
so
dtheta1/dt = theta2
Second order ODE is given below
d^2theta/dt^2 + b/m*dtheta/dt + g/L*sintheta = 0
Put the theta1 in the above equation
Equation becomes like below
d^theta1/dt^2 + b/m*dthet1/dt + g/L*sintheta1 = 0
Put the theta2 in the above equation
Equation becomes like below
dtheta2/dt + b/m*theta2 + g/L*sintheta1 = 0
dtheta1/dt = theta2 is the first order ode - Number 1
dtheta2/dt = -b/mtheta2-g/L*sintheta1 - number 2
Derivation breakup image

Here is the function script:
Function file name is ode_function
Inputs to ode_function are t,theta,b,g,l and m.
function [dtheta_dt] = ode_function(t,theta,b,g,l,m)
theta1 = theta(1)
theta2 = theta(2)
dtheta1_dt = theta2;
dtheta2_dt = -(b/m)*theta2-(g/l)*sin(theta1);
dtheta_dt = [dtheta1_dt; dtheta2_dt];
Put the two first order OED in the form of column vector shown above.
Here is the main simulation script:

This plot shows the how angular velocity and angular displacement changes with respect to time changes.
Here angular velocity starts from 3 radians/sec and angular displacement is starts from 0 radians.
Time starts from 0 to 20 sec range, We can see the angular velocity and angular displacement values.

Here we can analysis the angular displacement in radians versus angular velocity in radians/sec
Kindly find the attached vedio of the pendulum movement.
Thanks,
Siddesh R S