All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
SIMPLE PENDULUM MOTION WITH DAMPING
AIM :
To write a program to solve ordinary differential equation (ode) for equation of motion of a simple pendulum with damping and to create an animation for the motion of the pendulum.
THEORY :
GOVERNING EQUATIONS :
The way the pendulum moves depends on the Newtons second law. When this law is written down, we get a second order Ordinary Differential Equation(ode) that describes the position of the "ball" w.r.t time.
The 2nd order ode below represents the equation of motion of a simple pendulum with damping -
where, b=damping coefficient.
m = mass of the ball in kg,
g = gravity in ms2,
L = length of the pendulum in m.
In order to solve the equation of motion for pendulum and as the ode is of higher order we break the 2nd order ode into a series of 1st order ode.
The final ode equations to solve is represented as :
OBJECTIVES OF THE PROJECT:
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
%% Code for solving simple pendulum equation using ode45
clear all
close all
clc
% Inputs -
b = 0.05; % Damping
m = 0.1; % Mass in kg
g = 9.81 ; % Gravity
l = 1 ; % Length
% Initial Condition
theta_0 = [0 ; 5]; % Intializing the condition as 0 for displacement and 5 for velocity
% Time interval/ Time points
t_span = linspace(0,10,400);
% Solve ode equation using ode45 equation solver
[t,results] = ode45(@(t,theta) ode_func(t,theta,b,g,l,m), t_span, theta_0); %Calling the function saved ode_func to solve ode for pendulum
% Plot the displacement and velocity with respect to time
figure(1)
plot(t,results(:,1)) % Plotting time vs all rows in 1st column
hold on
plot(t,results(:,2)) % Plotting time vs all rows in 2nd column
xlabel('Time(t)')
ylabel('Plot of Displacement and Velocity')
legend('DISPLACEMENT','VELOCITY')
% Plot for different positions of pendulum for creating an Animation
counter_ct = 1;
THETA_displace = results(:,1);
for i = 1:length(THETA_displace)
THETA_0 = THETA_displace(i);
% Assigning the co-ordinates -
x0 = 0;
y0 = 0;
x1 = l*sin(THETA_0); % Get the equation from the geometery of the pendulum
y1 = -l*cos(THETA_0);
% Plotting the pendulum for motion
figure(2)
plot([-1.2 1.2],[0 0], 'linewidth',4,'color','b') % Plot for Fixed line
hold on
plot([0 0],[0 0],'o','markerfacecolor','k','markersize',8); % Plot for hinge point in fixed line
hold on
plot([x0 x1],[y0 y1], 'linewidth',3.5,'color','g') % Plot for pendulum string as line with green color
hold on
plot(x1,y1,'o','markersize',12,'markerfacecolor','r') % Plot for mass bob fixed to string
hold off
axis([-2 2 -2 1]) % Setting the axis limits in plot
pause(0.01)
E(counter_ct) = getframe(gcf); % Capturing figure and plot in frames and saving in Variable E
counter_ct = counter_ct + 1 ;
end
% Creating Movie and saving it in file
movie(E) % Creating movie for all the saved frames of plots in Variable E
videofile = VideoWriter('Simple Pendulum.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,E) % Writing the video file to movie frames saved to Variable E
close(videofile)
STEPWISE EXPLANATION OF THE CODE :
Errors faced while programming :
i.e. plot([x1 y1],'o','markersize',12,'markerfacecolor','r')
b. Error in creating a movie due to typo for command movie, so matlab cannot find the instruction to run further.
Screenshots showing errors in command window and in Plot :
Steps taken to overcome the Errors Faced –
i.e. plot(x1, y1,'o','markersize',12,'markerfacecolor','r')
CONCLUSION :
Analyse and understood the equation of motion with damping of a simple pendulum and created a program for solving ode for pendulum using ode45 equation solver for the transient behaviour of the system and animated the motion of the pendulum when the displacement changes with respect to time. In final output graph for displacement and velocity vs time we learned that as time increases then the displacement of the pendulum decreases so thus, the velocity for the motion of pendulum respectively.
Reference link for the animation
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
MBD Simulation on IC Engine Valve Train
AIM : To create models, assembly & perform Motion analysis for the IC engine valve train . OBJECTIVE : To obtain the results for Valve Lift. Calculate and display the plots for contact force between Cam and Push Rod, Pushrod and Rocker Arm, Rocker Arm and Valve. INTRODUCTION : In IC engines, valve…
08 Dec 2020 12:46 PM IST
STATIC ANALYSIS FOR A PLATE WITH HOLES
AIM : To perform the Static Analysis on two different models of a plate with the holes and the comparison of results among the two models. OBJECTIVE : Prepare a static analysis and get the output for stress, strain and displacement for two models of plate with holes. Compare the final results of static analysis for the…
08 Dec 2020 12:46 PM IST
EV battery module Benefits and Specifications
AIM : To study the benefits of using Battery modules and specifications of an individual module specified for an battery pack. INTRODUCTION : A battery is a device that converts chemical energy into electrical energy and vice versa. The composition of an EV battery might vary slightly depending on the types of electric…
08 Dec 2020 12:45 PM IST
Frequency Analysis of a rotating shaft
AIM : To perform frequency analysis for a rotating shaft with disc in solidworks. OBJECTIVE : Conduct a frequency analysis on the rotating shaft with disc. Determine the 5 different mode shapes and display its resonant frequencies. INTRODUCTION : The goal of modal analysis in a model is to determine the natural mode…
08 Dec 2020 12:44 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.