Week 3 - Solving second order ODEs
AIM: to create a program in matlab to solve the 2nd order ode of motion of a simple pendulam with damping.
THEORY :
In matheamatical an ordinary diffrential equation (ode) is adiffrential equatons contaning one or more function of one indipendent variable and the derivatives of those function.
Equation for second order



MATLAB PROGRAM:
clear all
close all
clc
b=0.05; % damping coefficient.
g=9.81; % acceleration due to gravity in
l=1; % length of the pendulam in M.
m=1; % mass of pendulam in KG.
%initial condition
theta_0=[0;3];
%time points
t_span=linspace(0,20,100);
%solve ode
[t results]=ode45(@(t,theta) ode_func(t,theta,b,g,l,m),t_span,theta_0);
%plotting
figure(1)
A=plot(t,results(:,1))
hold on
B=plot(t,results(:,2))
disp=results(:,1);
ct=1;
for i=1:length(t_span);
x0=0;
y0=0;
x1=l*sin(disp(i));
y1=-l*cos(disp(i));
figure(2)
plot([-2 2],[0 0],'linewidth',5)
hold on
plot([x0 x1],[y0 y1],'-o','markersize',3,'linewidth',5,'color','r');
plot(x1,y1,'-o','markersize',20,'markerfacecolor','k');
axis([-1.5 1.5 -1.5 1.5])
pause(0.03)
hold off
M(ct)=getframe(gcf)
ct=ct+1;
end
movie(M)
v=VideoWriter('pendulam.avi');
open(v)
writeVideo(v,M)
close(v)
Results;
- As seen in the graph , the pereodic curve of angular displacment and angular velocity reduce W.R Time . Thisb is manily due to the damping factor.This is the motion of simple pendulam is called as damped simple arnic motion.
- From the animation of motion of the simple pendulam , it can be conculded ,as the damping coefficient is increase ,the motion of the pendulam . Also increase in damping coefficient reduce the time taken by pendulam to reach equliliburium position .