All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim: Solving a simple pendulum's second-order ordinary differential equation and animating the damping effect. Objective: To change an ordinary differential equation of second order into an equation of first order. Using the built-in MATLAB function for solving ordinary differential equations to create the function.…
Arun Gupta
updated on 15 Nov 2022
Aim: Solving a simple pendulum's second-order ordinary differential equation and animating the damping effect.
Objective:
FACTORS ENTAILED:
θ'1=θ2
and θ'2=−(bmθ2)−gLsinθ1
Code Explanation:
Matlab Program:
%given data
%damping coefficient
b = 0.05;
%acceleration due to gravity
g = 9.81;
%length of Pendulum in meters
l = 1;
%mass
m = 1;
%time duration for simulation
t_s = linspace(0,30,100);
%angular displacement & velocity
y_starting = [0;3];
%using ODE45
a = @(t,y)ode_second_order_pendulum(y,b,m,l,g);
[t,y]= ode45(a,t_s,y_starting);
%Plot of angular displacement & velocity w.r.t time function.
figure(1);
grid on
subplot(1,2,1)
plot(t,y(:,1));
title('Displacement vs Time');
xlabel('Time in seconds');
ylabel('Angular displacement in rad');
subplot(1,2,2)
plot(t,y(:,2));
title('Angular velocity Vs Time')
xlabel('Time in seconds');
ylabel('Angular velocity in rad/sec');
grid off
saveas(figure(1),'subplot','jpg')
%polar co-ordinate to cartesian co-ordinate
y1 = -1*cos(y(:,1));
x1 = 1*sin(y(:,1));
%video for pendulum motion
for i = 1:100
figure(2)
plot([0 x1(i)],[0 y1(i)],'linewidth',3,'color','r');
hold on
plot(x1(i),y1(i),'marker','o','linewidth',10,'markerfacecolor','g');
plot([-1.2 1.2],[0 0],'linewidth',3,'color','b');
axis([-1.2 1.2 -1.2 1.2]);
title(['Time: ', num2str(t_span(i))]);
M(i) = getframe(gcf);
close(2)
end
movie(M)
videofile = VideoWriter('simplependulum.avi','Uncompressed AVI');
open(videofile);
writeVideo(videofile,M)
close(videofile)
The Function is given as follows;
function ydot = ode_second_order_pendulum(y,b,m,l,g)
ydot = [y(2);-(b/m)*y(2)-(g/l)*sin(y(1))];
end
Output:
The graph illustrates that the damping factor causes the displacement to reduce as we advance in time. The plot makes it clear that displacement starts at 0 as the initial condition. The angular velocity vs. time plot shows that it began at 3 rad/sec and has since dropped significantly.
Conclusion:
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...
Project 1 : Flow over Ahmed Body
Flow over Ahmed's Body The Ahmed body represents a simplified, ground vehicle geometry of a bluff body type. Its shape is simple enough to allow for accurate flow simulation but retains some important practical features relevant to automobile bodies. This model describes how to calculate the turbulent flow field around…
24 Nov 2023 05:24 AM IST
Project 1 : CFD Meshing for Tesla Cyber Truck
Objective : To Identify & clean up all the topological errors in the given Tesla Cyber Truck Car model. To create a surface mesh. To Create a wind tunnel around Tesla Cyber Truck Car. To create a volumetric mesh to perform an external flow CFD analysis simulation. Introduction : ANSA : ANSA is a Computer-aided engineering tool…
09 Sep 2023 11:52 AM IST
Project 1 - Meshing of Floor Panel
AIM:- To mesh the given floor panel for the given quality criterias without any failure in the elements. Project description:- FLOOR PANEL GIVEN:- Procedures for Meshing a 2D component:- i) Importing the CAD model into ANSA:- The cad model is imported into the Ansa software by clicking File ---> New command. ii) Geometry…
04 Mar 2023 05:12 AM IST
Project 1 : CFD Meshing for Tesla Cyber Truck
Objective : To Identify & clean up all the topological errors in the given Tesla Cyber Truck Car model. To create a surface mesh. To Create a wind tunnel around Tesla Cyber Truck Car. To create a volumetric mesh to perform an external flow CFD analysis simulation. Introduction : ANSA : ANSA is…
04 Mar 2023 05:05 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.