Week 3 - Solving second order ODEs
AIM : TO SOLVE SECOND ORDER ORDINARY DIFFERENTIAL EQUATION USING MATLAB
THEORY:
ordinary differential equations(ODES)- an ode is a differential equation containing one or more functions of one independent variable and the derivations of the function the term ordinary is used in contrast with the term partial differential equation which may be with respect to more than one independent variable.
simple pendulum- the simple pendulum is an idealized mathematical model of a pendulum .this is a weight on the end of a massless code suspended from a pivot ,without friction .when we gave ainitial push,it will swing back and fourth at constant amplitude .real pendulums are subjected to friction and air drag ,so the amplitude of their swings declines. the point from which the bob is suspended is known as point of suspension .weight of the bob acts vertically downwards and the tension acts vertically upwards ,so the bob comes under equilibrium position and the bob starts oscilating if even smaller external force is applied
GOVERNING EQUATIONS-
θ is the angle made by the movable link with vertical axis.
l is the length of the movable rod
m is the masses of bob,b is damping coeffecient of the system .
1.d^2θ/dt^2+b/m.d(θ)/dt+g/lsinθ = 0 second order ode--------(1)
to solve this ode we nrrd to reduce the order of equation into lower order
letθ = θ1
so this implies d(θ)/dt=d(θ1)/dt=θ2----------(2)
therefore d^2θ/dt^2=d^2θ1/dt^2=d(θ2)/dt---------(3)
putting the value of (2)and(3) in (1) we get
d^2θ1/dt+b/m.d(θ1)/dt+g/l.sinθ1 = 0
therefore,d(θ2)/dt+b/m.(θ2)+g/l.sinθ1 = 0
we got ,d(θ2)/dt = -b/m.(θ2)-g/lsinθ1
OBJECTIVES-
1.to solve the second order ODE with graph of velocity and displacement
PROCEDURE-
given details-
simulate the motion between 0-20sec
angular displacement = 0
angular velocity = 3rad/sec
time t= 0
l = 1meter
m = 1kg
b = 0.05
g = 9.81m/s^2
MAT LAB CODE FILE
1 .code function of ode45 for main program
function [dtheta_dt] = ode_func(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];
end
2. main ode program
clear all
close all
clc
b= 0.05;
g= 9.81;
l= 1;
m= 0.1;
% initial condition
theta_0 = [0;5];
% time points
t_spam = linspace(0,10,500);
% solve ODE
[t, results] = ode45(@(t,theta) ode_func(t, theta, b,g,l,m),t_spam,theta_0);
plot(t,results(:,1))
hold on
plot(t,results(:,2))
ylabel('plot')
xlabel('plot')
CODE EXPLANATION-
1.firstly the given details are assigned as variables in the code .then time span of given pendulum is set by using linspace command then theta value is given as a column matrix .after we use ode45 function and corresponding 'ode_func' function call in main program
2.then used plot command to plot graph corresponding to time and velocity ,legend command is used for identity each values in the graph
3.for getting the accurate simulation of the simple pendulum corresponding to second order ode with damping we need to use looping statements
4. the pendulum has fixed cordinates menstioned as x0,y0and x1,y1 are the other cordinates
RESULTS-
OUTPUTS-
1. graph for the velocity v/s time which shows displacement and angular velocity-

the displacement (blue color) and angular velocity (red color) is decreasing by the increased time ,this is due to introduction of damper
CONCLUSION-
1. the graph of displacement and angular velocity is plotted in velocity v/s time diagram