All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
1. OBJECTIVE - SOLVING 2ND ORDER ODE OF SIMPLE PENDULUM WITH DAMPING. code : clear all close all clc %inputs %Damping coefficient b=0.05; %gravity in m/s^2 g=9.81; %length of the pendulum in m; l=1; %mass of the ball in kg m=1; %initial condition of angular displacement & angular velocity theta=[0;3];…
ARNALD ANTONY
updated on 28 Feb 2022
1. OBJECTIVE - SOLVING 2ND ORDER ODE OF SIMPLE PENDULUM WITH DAMPING.
code :
clear all
close all
clc
%inputs
%Damping coefficient
b=0.05;
%gravity in m/s^2
g=9.81;
%length of the pendulum in m;
l=1;
%mass of the ball in kg
m=1;
%initial condition of angular displacement & angular velocity
theta=[0;3];
%time points ;
time=linspace(0,20,180);
%solve ODE
[t, results]=ode45(@(t,theta)ode_func(t,theta,b,g,l,m),time,theta);
%plotting
subplot(2,1,1)
plot(t, results(:,1));
xlabel('time')
ylabel('Angular displacement')
grid on
subplot(2,1,2)
hold on;
plot(t,results(:,2));
xlabel('time')
ylabel('Angular velocity')
grid on
%ANIMATION OF SIMPLE PENDULUM
%inputs
X0 = 0;
Y0 = 0;
ct=1;
%for loop
for i=1:length(t)
%coordinates
X1=l*sin(results(i,1));
Y1=-l*cos(results(i,1));
%plotting
figure(2)
plot([-1 1],[0 0],'linewidth',5,'Color','g')
axis([-2 2 -2 2]);
line([X0 X1],[Y0 Y1],'linewidth',2,'color','b');
hold on;
plot(X0,Y0,'O','markersize',5,'markerfacecolor','y')
plot(X1,Y1,'O','markersize',20,'markerfacecolor','r')
title('DAMPING OF SIMPLE PENDULUM');
legend('Support rod','length of pendulum','Fixed point','Bod of pendulum')
grid on
hold off
M(ct)=getframe(gcf);
ct=ct+1;
end
movie(M)
videofile = VideoWriter('simple_pendulum.avi','Uncompressed AVI');
open(videofile);
writeVideo(videofile,M);
close(videofile);
RESULTS:https://drive.google.com/file/d/1waWvDl7_INLljMYEk_wUGGj6Yr9soQ7X/view?usp=sharing
EXPLANATION :
code :
1.clear all - it is used to remove all the variables from the current workspace,clearing from them from system memory.
2.close all - deletes all the figures whose handles are not hidden.
3.clc - it is used to clear the command window.
4.inputs- it includes the variables such as damping coefficient, length of the pendulum, gravity & mass of the ball.
5.initial condition of angular displacement & angular velocity.
6.Time array is created from 0sec to 20 sec with 180 values in between using linspace command.
7. calling of ODE45 function with the input parameters t,theta,b,g,l,m followed by time array & intial condition corresponding to starting of the time.
8.plot- plotting is used to plot the graph between time vs angular displacement and time vs angular velocity using the subplot.
9.xlabel is used to to name the graph in x-axis & ylabel to name the graph in the y-axis.
10.grid on- it is used to on the grid on the graph.
Animation of simple pendulum :
1.coordinates x0 and y0 are assinged to 0 which is fixed.
2.ct is set to 1.
3.for loop is used in which i is iterated from 1 to the length of t in which coordinates x1 and y1 are assigned.
4.plot-plot is used to plot the coordinates with linewidth of 5 & color 'green'.
5.axis is provided with the given coordinates.
6. line is plotted using the coordinates with the linewidth of 2.
7. A shape 'o' is created in the fixed coordinates having a size of '5' by using 'markersize' command and having a 'yellow' color by using 'markerfacecolor' command.
8.A shape 'o' is created at the end of the pendulum having a size of '20' by using 'markersize' command and having a 'red' color by using 'markerfacecolor' command.
9. legend is used to differentiate between support rod, lenght of the pendulum, fixed point & bod of pendulum.
10. getframe commant is used to saved the figures in the array 'M'.
11.movie(M) is used to create a videofile with the help of VideoWriter commant in AVI format.
12. openvideo command is used to open the file, closevideo command is used to close the file.
result :
it is the animation of simple pendulum with damping by solving 2nd order ODE.
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...
Advanced Sheet Metal Design Using NX Cad Challenge_5_Odd Shaped Enclosure
Advanced Sheet Metal Design Using NX Cad Challenge 5 Odd Shaped Enclosure Title of the Project: Advanced Sheet Metal Design Using NX Cad Challenge 5 Odd Shaped Enclosure Objective: To design a Odd shaped Enclosure with the help of NX advance sheet metal. Introduction: Sheet metal is metal formed by an industrial…
24 Jan 2023 05:34 PM IST
Advanced Sheet Metal Design Using NX Cad Challenge_2_Box Assembly
AIM : Advanced sheet metal design using NX cad challenge 2 Box Assembly . OBJECTIVE : To design a BOX Assembly using Siemens NX sheet metal application. INTRODUCTION : SHEET METAL is metal formed by an industrial process…
24 Jan 2023 07:10 AM IST
Advanced Sheet Metal Design Using NX Cad Challenge_1_Casing Design
Design of casing by using NX cad OBJECTIVE :- To design a sheet metal casting…
23 Jan 2023 11:03 AM IST
Fender Design - Wheel Arch Challenge
Aim : To calculate the wheel arch gap at required points and check whether the car passes the European standard. Objective : Study about the different wheel arch gap standards. Draw the lines at the required angle and points for the European standard. Measure the distance at each angles and mention…
16 Jan 2023 03:29 PM 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.