Project

SIMULATION OF MOTION OF A SIMPLE PENDULUM

AIM:

To simulate the motion of a SIMPLE PENDULUM.

SOFTWARE:

MATLAB.

THESIS:

A Simple Pendulum consists of a Bob attached to a String. the bob is suspended from a rigid support by means of a string so that it can swing freely. this motion of the simple pendulum can also be termed as Oscillatory Motion. the Bob is a ball having a certain mass. in this case, we consider that the bob has a mass of 1Kg. the string has a mass which is negligible,but is strong enough to be under tension. in this case we consider the length of the string to be 1 meter.

In this project, we simulate the motion of the simple pendulum between 0-20sec, having an Angular displacement = 0 and Angular velocity = 3 rad/sec. the other condition are listed below,

Length of the string(L)=1 metre,

weight of the bob(m)=1 kg,

damping co-efficient(b)=0.05.

acceleration due to gravity(g)=9.81 m/s^2.

MATHEMATICAL FORMULA:

The following are the formula governing the simulation,

1 . `(d^2theta)/dt^2+ b/m(d theta)/dt+g/lsintheta=0`

PROGRAM TO GENERATE THE SIMULATION:

close all
clc

%damping coefficient
  b=0.05;
%acceleration due to gravity  
  g=9.81;
%length of the pendulum
  l=1;
%mass of the bob 
  m=1;

%initial condition
theta_0 = [0;3];

%time points
t_span = linspace(0,20,500);

%solving ODE
[t,results] = ode45(@(t,theta) ode_func(t, theta, b,g,l,m), t_span, theta_0);

figure(1)

grid on
plot(t,results(:,1))
hold on
plot(t,results(:,2))
xlabel('plot')
ylabel('time')
legend('displacement','velocity')

figure(2)
%pendulum animation
 

ct=1;

for i = 1:length(results)
    THETA = results(i,1);
    x0=0;
    y0=0;
    x1= l*sin(THETA);
    y1= -l*cos(THETA);
    plot([x0,x1],[y0,y1],'LineWidth',3)
    hold on
    plot(x1,y1,'o','MarkerSize',20,'MarkerFaceColor','r','LineWidth',3)
    pause(0.03)
    axis([-2 2 -2 0])
    M(ct) = getframe(gcf);
    ct = ct+1;
    hold off
end
    
movie(M)
videofile = VideoWriter('simple_pendulum.avi', 'uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

PROGRAM TO SOLVE THE 2ND ODE:

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

OUTPUTS GENERATED:

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.