All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM: To write a program that solves the ODE representing the equation of motion of a simple pendulum with damping and to produce the simulation of motion for this damped oscillation. OBJECTIVE: To write the neccessary code to solve the 2nd order ODE of damped harmonic motion using MATLAB. To plot the angular displacement…
Naveen Gopan
updated on 27 May 2021
AIM:
To write a program that solves the ODE representing the equation of motion of a simple pendulum with damping and to produce the simulation of motion for this damped oscillation.
OBJECTIVE:
THEORY:
In Engineering, ODE is used to describe the transient behavior of a system. A simple example is a pendulum.
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 that describes the position of the "bob" with respect to time.
Similarly, there are hundreds of ODEs that describe key phenomena and if you have the ability to solve these equations then you will be able to simulate any of theses systems.
When the motion of an oscillator reduces due to an external force, the oscillator and its motion are damped. These periodic motions of gradually decreasing amplitude are damped simple harmonic motion. An example of a damped simple harmonic motion is a simple pendulum.
In the damped simple harmonic motion, the energy of the oscillator dissipates continuously. But for a small damping, the oscillations remain approximately periodic. The forces which dissipate the energy are generally frictional forces.
The general ODE equation we are trying to solve here is this:
∂2θ∂t2+bm⋅∂θ∂t+gL⋅sinθ=0
Where,
θ = Angular Displcement in radians
b = Damping Coefficient
m = Mass of the pendulum in kg
g = Acceleration due to gravity in ms2
L = Length of the pendulum in meter (m)
SIMPLIFYING THE 2ND ORDER ODE TO SOLVE IT USING MATLAB:
Assume, θ=θ1
∂θ∂t=∂θ1∂t=θ2
∂θ12∂t2=∂θ2∂t
Equation Becomes:
∂θ2∂t+bm⋅θ2+gL⋅sinθ1=0
2nd order ODE reduces to two 1st order ODE:
∂θ1∂t=θ2
∂θ2∂t=−bm⋅θ2−gL⋅sinθ1
MAIN CODE OF THE PROGRAM:
clear all
close all
clc
g=9.81; % Acceleration due to gravity in m/s2
L=1; % length of the pendulum in meter
b=0.05; % damping coefficient
m=1; % mass of the pendulum in kg
t = [0 20]; % time period of the harmonic motion/limits
theta0 = [0 3]; % initial and boundary conditions of angular displacement
[t theta]= ode45(@(t,theta) odefun_second_order_pendulum(t,theta,g,L,b,m),t,theta0); % solving the 2nd order ODE using the function odefun_second_order_pendulum
figure(1)
plot(t,theta(:,1),t,theta(:,2)) % Plotting the angular dispcement and angular velocity vs time graph of the specified motion
ylabel('Angular Displacement and Angular Velocity')
xlabel('Time')
legend('Angular Displacement(rad)','Angular Velocity(rad/sec)')
% Code for animation of the pendulum
ct=1; % Initialising loop counter
for i=1:length(t)
figure(2)
plot([-1 1],[0 0]); % plotting the wall where the pendulum is fixed
axis([-1.5 1.5 -1.5 1]); % defining the limits of values in the x and y axis
hold on
plot(L*sin(theta(i,1)),-L*cos(theta(i,1)),'o','markersize',20,'markerfacecolor','w'); % plotting the bobof the pendulum
hold on
plot([0,L*sin(theta(i,1))],[0,-L*cos(theta(i,1))],'b'); % Plotting the string of the pendulum
hold off
M(ct)=getframe(gcf); % stiching all frame in M array to create an animation
ct=ct+1;
end
movie(M)
videofile = VideoWriter('Damped_Pendulum.avi', 'Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
FUNCTION CODE:
function [thetadot] = odefun_second_order_pendulum(t,theta,g,L,b,m)
thetadot = zeros(2,1);
thetadot(1)= theta(2);
thetadot(2)= ((-b/m)*theta(2)) - ((g/L)*sin(theta(1)));
end
OBSERVATIONS/OUTPUT:
Variation of Angular Displacement and Angular Velocity with respect to time
SIMULATION OF THE DAMPED HARMONIC MOTION OF PENDULUM :
CONCLUSION:
Link To Code: https://drive.google.com/file/d/1zxyl6aUGeNIdXoBsvVLIfGm78q_A4_W4/view?usp=sharing
https://drive.google.com/file/d/14GY4ekT2m4DOOKBU667_Jron4LZpkf-L/view?usp=sharing
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...
Week 3.5 - Deriving 4th order approximation of a 2nd order derivative using Taylor Table method
AIM: Derive the following 4th order approximations of the second-order derivative. 1. Central difference 2. Skewed right-sided difference 3. Skewed left-sided difference After deriving these schemes, prove that your skewed schemes are fourth-order accurate Writing a program in Matlab to evaluate the second-order…
02 Jun 2021 02:17 PM IST
SIMULATION OF DAMPED HARMONIC MOTION OF A SIMPLE PENDULUM USING MATLAB
AIM: To write a program that solves the ODE representing the equation of motion of a simple pendulum with damping and to produce the simulation of motion for this damped oscillation. OBJECTIVE: To write the neccessary code to solve the 2nd order ODE of damped harmonic motion using MATLAB. To plot the angular displacement…
27 May 2021 01:49 PM IST
STOICHIOMETRIC COMBUSTION COEFFICIENT CALCULATOR USING MATLAB
AIM: 1. Write functions to calculate the stoichiometric co-efficient (ar) for each fuel 2. Show a plot that compares the effect of number of atoms of carbon on the stoichiometric co-efficient "ar". Compare how this trend changes with the fuel type (alkane, alkene and alkyne). THEORY: Combustion or burning is a high…
25 May 2021 11:08 AM IST
DESIGN OF A BY-PASS VALVE
AIM: Design of a Solenoid in-line By-Pass Valve with Inlet Día of ∅9 mm and Outlet Día of ∅11 mm using Autodesk Inventor. SOLENOID VALVE: A solenoid valve is an electromechanically operated valve. Solenoid valves differ in the characteristics of the electric current they use, the strength of the…
01 Nov 2020 10:12 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.