Week 3 - Solving second order ODEs
Aim:
Write a Program to solve the 2nd order ODE & Simulate the simple pendulum by using MATLAB
Objective:
A Program to calculate angular velocity and angular displacement
Simple Pendulum:
Principle:
Simple Pendulum is an ideal pendulum consisting of a mass by a weightless inextensible perfectly flexible thread and free to vibrate without friction. It is an mechanical system that moves in an oscillatory motion.
Second Order Differential Equation:
The Order of a differential equation is the highest order deriative.Thus ,a second order differential equation is one in which there is a second derivative but not third or higher derivative.

%2ND Order ODE
clear all
close all
clc
b=0.08;
g=9.81
l=2;
m=0.5;
%intial condition
theta_0=[0;10];
%time points
t_span=linspace(0,10,500);
%solve ODE
[t,result]=ode45(@(t,theta) ode_func(t,theta,b,g,l,m),t_span,theta_0);
for i=1:length(result)
THETA=result(i,1);
x1=l*sin(THETA);
y1=-l*cos(THETA);
x0=0;
y0=0;
figure(1)
plot([x0,x1],[y0 y1])
hold on
plot(x1,y1,'marker','o','markersize',10)
end
figure(2)
plot(t,result(:,1))
hold on
plot(t,result(:,2))
xlabel('time')
ylabel('plot')
%
% %plotting
% %plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linwidth',3);
% grid on
%
% M(ct)=get frame(gcf);
%
% %Creating Movie of 2nd order ode
% movie(m)
% videofile=videowriter('pendulum.avi', 'Uncompressed avi');
% open(videofile);
% writevideo(videofile,m);
% close(videofile);