All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim - Using ODE (Ordinary Differential Equation) to describe the transient behaviour of simple Pendulum. Objective - Our objective here is to write a code for solving a 2nd Order ODE to simulate the motion of a simple Oscillating Bob aka Pendulum. We have used the following data which was provided by Skill-Lync.…
Prahar Dave
updated on 02 Dec 2020
Aim - Using ODE (Ordinary Differential Equation) to describe the transient behaviour of simple Pendulum.
Objective -
Our objective here is to write a code for solving a 2nd Order ODE to simulate the motion of a simple Oscillating Bob aka Pendulum. We have used the following data which was provided by Skill-Lync.
1 - 2nd Order ODE.
2 - l =1 metre,
3 - m=1 kg,
4 - b=0.05.
5 - g=9.81 m/s2.
and then simulate the motion between 0-20 sec, for angular displacement =0 and angular velocity=3 rad/sec at time t=0.
%Simple pendulum
clear all
close all
clc
% Inputs
z=0.05; %damping_coefficient (Zeta)
g=9.81; %gravity
l=1; %length
m=1; %mass
%initial condition
theta_0 = [0;3]; %initial displacement and initial velocity
%time point
t_span = linspace(0,20,300); %since given time is 20s
% solving ODE
[t,results]= ode45(@(t,theta) ode_func(t,theta,z,g,l,m),t_span,theta_0); %ode45 is built in Matlab function
plot(t,results(:,1),'linewidth',1.5)
hold on
plot(t,results(:,2),'linewidth',1.5)
ylabel("Displ./Velo.")
xlabel("Time(Sec.)")
legend('Displ','Velo.')
% to get the coordinates of Bob
theta2 = results(:,1)
count = 1;
x0=0;
y0=0;
for i = 1:length(theta2);
theta3 = theta2(i);
% coordinates of movement
x1= l*sin(theta3);
y1= -l*cos(theta3);
figure(2)
plot([-1 1],[0 0],'linewidth',2)
hold on
plot([x0 x1],[y0 y1],'color','b','linewidth',2)
hold on
plot(x1,y1,'o','markers',20,'markerfacecolor','r')
hold off
axis([-1.5 1.5 -1.5 0.25])
grid on
xlabel('Damped pendulum')
pause(0.002)
M(count)=getframe(gcf);
count=count+1
end
movie(M)
videofile= VideoWriter('damped pendulum.avi','uncompressed avi');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Plot -
Link to see the Animated vide of Pendulum -
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...
Hood design-Week 2
Hood - The Hood/Bonnet is an opening body panel or BiW part, which covers the front of a vehicle It covers the engine room in case of the front-engine vehicles and luggage room in rear-engine ones A hood is similar to a door Commonly used materials in Hood - These materials are selected based on the required properties…
14 Sep 2022 06:56 AM 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.