Project

Pendulum - Second Order ODE

Pendulum Motion Analysis

The purpose of this project is to solve a second order differential equation which governs the motion of a simple pendulum. The motion of pendulum depends on the Newtons Second Law and follows the second order ODE given by:

In the above equation,

g = gravity in m/s2,

L = length of the pendulum in m,

m = mass of the ball in kg,

b=damping coefficient.

Problem Specifications :

L=1 metre,

m=1 kg,

b=0.05.

g=9.81 m/s2.

Simulate the mtion between 0-20 sec, for angular displacement=0,angular velocity=3 rad/sec2 at time t=0.

Angular Displacement and Angular Velocity plots were generated for a working time range of 20 secs.

\"\"

Also, to get a visualization of the path followed by pendulum, an animation was created using MATLAB.

Youtube Link : https://youtu.be/zR-nVgQZLp8

Matlab Code:

clear all; clc
% Given System Data
% g = gravity in m/s2, L = length of the pendulum in m, m = mass of the ball in kg, b=damping coefficient
L=1; m=1; g=9.81; b=0.05;

t0 = [0 20]; % Time-span in secs
theta0 = [0 3]; % Angular Displacement = 0 radians and angular velocity = 3 rad/sec at t=0 (Initial Conditions)

% Solving ODE
[t,x] = ode45(@(t,theta) pendulum(L,m,g,b, t,theta),t0,theta0);

Angular_Velocity = x(:,2);

subplot(1,2,1);
plot(t,x(:,1));
xlabel(\'time (sec)\');
ylabel(\'Angular Displacement (radians)\');
title(\'Angular Displacement Plot\')
subplot(1,2,2);
plot(t,x(:,2));
xlabel(\'time (sec)\');
ylabel(\'Angular Velocity (rad/sec)\');
title(\'Angular Velocity Plot\')

% Animation

% Origin
O = [0 0];

for(i=1:length(t))

axis(gca,\'equal\');
axis([-1.2 1.2 -1.2 0.5]);
grid on;

x0=0;
y0=0;
x1 = L*sin(x(i,1));
y1 = -L*cos(x(i,1));

P = [x1 y1];

hinge1 = line([-0.5 0.5], [0 0]);
hinge2 = line([-0.5 0.5], [0.02 0.02]);
hinge3 = line([-0.5 0.5], [-0.02 -0.02]);
hinge4 = line([-0.5 -0.5], [0.02 -0.02]);
hinge5 = line([0.5 0.5], [0.02 -0.02]);

Circ = viscircles(O,0.015);
String = line([x0 x1], [y0 y1]);
Bob = viscircles(P,0.1);

pause(0.001); 

  if(i<length(t))
    delete(Circ);
    delete(Bob);
    delete(String);
  end
end
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.