All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective - To understand the motion of simple pendulum using MATLAB. Explanation - A simple pendulum consists of a mass m, string of length l which is attached to the mass, where one end of string is fixed and the other end is freely suspended where the mass is attached. When the ball(mass) in equilibrium is…
Aditya Bhirdikar
updated on 27 Mar 2020
Objective - To understand the motion of simple pendulum using MATLAB.
Explanation - A simple pendulum consists of a mass m, string of length l which is attached to the mass, where one end of string is fixed and the other end is freely suspended where the mass is attached.
When the ball(mass) in equilibrium is subjected to an external force, displacement takes place and ball oscillates to and fro along the vertical plane. This motion can be described in mathematical form and code can be written in MATLAB to get the actual representation of motion.
A simple pendulum is the best example of ODE which describes the transient behaviour of a system.
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 "ball" w.r.t time.
Equation - This below second order ODE represents the equation of motion of a simple pendulum with damping.
where, b = damping co-effecient
L = length of the pendulum string in m
m = mass of the ball in kg
g = gravitational force in m/sec^2
Steps Involved -
% Program which describes the solving of second order equation
clear all
close all
clc
% inputs
l = 1;
m = 1;
b = 0.05;
g = 9.81;
% initial condition
theta_01 = [0;3];
% time condition
t_span = linspace(0,20,100);
% solve
[t,results] = ode45(@(t,theta) ode_func(t,theta,b,g,l,m),t_span,theta_01);
% plotting
plot(t,results(:,1))
hold on
plot(t,results(:,2))
xlabel('time')
ylabel('plot d & v')
% program to animate the simple pendulum
l1 = 1;
ct=1;
for i = 1:length(t_span)
x = 0;
y = 0;
x1 = l1*sind(results(i,1));
y1 = -l1*cosd(results(i,1));
figure(2)
plot([x x1],[y y1],'color','r','linewidth',3)
hold on
axis([-0.1 0.1 -1.4, 0.5])
plot(x1,y1,'-o','markers',25,'markerfacecolor','g')
pause(0.3)
M(ct) = getframe(gcf);
hold off
ct = ct+1;
end
movie(M)
videofile = VideoWriter('ode_func.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
% function defintion for the pendulum 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];
Figure1 - Plot showing the rate of change of angular displacement & angular velocity w.r.t time.
Figure 2 showing the piece of animation
Inference - The time t is independent variable, where as the theta is dependent variable.
With varying the damping co-effecient values we can obtain a smooth curves of angular displacement & angular velocity with respect to time.
youtube video link -youtu.be/ouPFScAnOFA
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 12- Final project
Final project - Door trim Inner Panel Role of plastic in the automobile industry: The use of polymers as plastics in the construction of automobiles has continued to grow over the last decades. Nowadays they are the second most commonly found in cars. Here are four reasons why plastic is used in car manufacturing:…
27 Mar 2023 10:20 AM IST
Week 10- Assembly Workbench
1. All the individual parts are modeled in the part design workbench with appropriate dimensions. 2. They are put in one assembly. 3. Applied with necessary constraints on it.
24 Feb 2023 11:41 PM IST
Week 9 - Project - A pillar Design with Master Section
1. For the given Class A surface dessign. 2. The Class B surface is created . 3. Class C surface is also created. 4. Finally the dog is created using the master section. 5.At last it is draft analysed.
24 Feb 2023 11:29 PM IST
Week 9 - Project 1 - Door Trim Lower with Engineering Features
1. For the Given Class A surface draft analysis is done on it. 2. By offsetting the Class B surface, the fillets which were failing were recreated. 3. Finally by using the reference to the surface of method/ by draft direction method there is a class C surface creation done. 4. Wherever required the heat stakes and locator…
24 Feb 2023 11:17 PM 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.