All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
SIMPLE PENDULUM AIM: To create an animation of simple pendulum by using second order differential equation by using ode solver function. For simulation the second order equation of the simple pendulum is: To create a plot between angular velocity and displacement of simple pendulum by using ode45. CONCEPT: For a simple…
Dhanu Manthri
updated on 01 Aug 2022
SIMPLE PENDULUM
AIM:
CONCEPT:
Where
b = damping coefficient (N-m/s)
m = mass of the bob (kg)
g = gravitational acceleration (m/s)
l = length of the string to connect bob (m)
OBJECTIVE:
Let us consider
θ = θ1 ------ (1)
dθ/dt = dθ1/dt = θ2 ------(2)
d2θ/dt2 = dθ2/dt -------(3)
dθ2/dt = -(b/m) * θ2 – (g/l) * sinθ
program for the simple pendulum:
%program for simple pendulum using ode45.
clear all
close all
clc
%input variables for the secound order ode of a simple pendulum
b = 0.05;
g = 9.81;
l = 1;
m = 0.1;
theta_0 = [0; 3];
t_span = linspace(0,20,500);
%ode 45 function to solve second order ode.
[t,results] = ode45(@(t,theta) ode_func(t,theta,b,g,l,m),t_span, theta_0 );
%plotting of angular velocity and displacement
figure(1)
plot(t,results(:,1))
hold on
plot(t,results(:,2))
grid on
title('motion of pendulum')
xlabel('time in sec')
ylabel('angular velocity(rad/s)/displacement(rad)')
legend('displacement','angular velocity')
angle = results(:,1);
%count command for iterations.
ct = 1;
for i = 1 : length(angle)
omega = angle(i);
figure(2)
title('motion of pendulum')
%fixed corordinates of one end of simple pendulum.
x0 = 0;
y0 = 0;
%moving coordinates of the bob.
x1 = l*cos((3*pi/2)+omega);
y1 = l*sin((3*pi/2)+omega);
%plotting of the bob motion.
plot([x0 x1],[y0 y1],'linewidth',3,'color','g');
hold on;
plot(x1,y1,'o','markers',15,'MarkerFaceColor','k');
hold on;
plot([-3 3],[0 0],'linewidth',2,'color','b');
hold off
axis([-3 3 -2 2])
grid on
pause(0.1)
M(ct) = getframe(gcf);
ct = ct+1;
end
%to create a animation of the simple pendulum
movie(M)
videofile = VideoWriter('simple_pendulum.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
ode function program:
function [dtheta_dt] = ode_func(t,theta,b,g,l,m)
theta1 = theta(1);
theta2 = theta(2);
dtheta1_dt = theta(2);
dtheta2_dt = -(b/m)*theta2 - (g/l)*sin(theta1);
dtheta_dt = [dtheta1_dt; dtheta2_dt];
end
PROGRAM EXPLANATION:
[t, results] = Ode45(@ (t, y) ode (t, y, args), t_span, y0).
ERRORS:
OUTPUT:
CONCLUSION:
animation of simple pendulum:
https://drive.google.com/file/d/1e3LQvnc7fE9Z2G8u-AXLxlHnCcXvbi2e/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 14 challenge
AIM : To assemble the Butterfly Valve by using the sub parts created and apply the GD&T to the Butterfly Valve assembly drawing.Introduction:Butterfly Valve:A butterfly valve is a valve that isolates or regulates the flow of a fluid. The closing mechanism is a disk that rotates. A butterfly valve is from…
08 Nov 2024 01:47 PM IST
Week 12- Final project
DEVELOPEMET OF DOOR TRIM PANEL AIM: To develop a door trim panel following the design…
28 Mar 2024 05:54 AM IST
Week 11 - Project - A pillar Design with Master Section
A PILLAR DESIGN WITH MASTER SECTION AIM: To create the A Pillar Design with the master section given as the…
14 Mar 2024 06:16 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.