All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM:- To write a program in Matlab\Octave that will simulate the pendulum motion Theory:- In mathematics, an ordinary differential equation (ODE) is a differential equation containing one or more functions of one independent and the derivatives of those functions. The term ordinary is…
MD TAUFIQUE SAMDAANI
updated on 24 May 2020
AIM:-
To write a program in Matlab\Octave that will simulate the pendulum motion
Theory:-
In mathematics, an ordinary differential equation (ODE) is a differential equation containing one or more functions of one independent and the derivatives of those functions. The term ordinary is used in contrast with the term partial differential equation which may be with respect to more than one independent variable.
In Engineering, ODE is used to describe the transient behavior of a system. A simple example is a pendulum
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.
Similarly, there are hundreds of ODEs that describe key phenomena and if you have the ability to solve these equations then you will be able to simulate any of theses systems.
In the above equation,
g = gravity in m/s2,
L = length of the pendulum in m,Write a program in Matlab\Octave that will simulate the pendulum motion,
m = mass of the ball in kg,
b=damping coefficient.
Objective:-
Details given:-
L=1 metre,
m=1 kg,
b=0.05.
g=9.81 m/s2.
Simulate the motion between 0-20 sec, for angular displacement=0,angular velocity=3 rad/sec at time t=0.
Code:-
Main Program
clear all
close all
clc
%inputs
b=0.05;
g=9.81;
m=0.1;
l=1;
%initial condition
theta_0=[0;5];
%time points
t_span=linspace(0,10,500);
%Slove ODE
[t,results]=ode45(@(t,theta)ode_func(t,theta,b,g,l,m),t_span,theta_0);
% Plotting Oscillation Graph of Simple Pendulum
subplot(5,4,[13,14,17,18]);
plot(t, results(:,1),'color','b');
hold on
plot(t,results(:,2),'color','r');
ylabel('Velocity & Displacement Osillation')
xlabel('Time 0-20 Sec')
title('Oscillation Graph of Simple Pendulum')
grid on
legend('Angular Displacement','Angular velocity')
hold off
subplot(5,4,[15,16,19,20]);
plot(results(:,1),results(:,2));
%Creating the Pendulum and plotting
ct=1;
for i=1:length(t_span)
x0=0;
y0=0;
x1=l*sin(results(i,1));
y1=-l*cos(results(i,1));
subplot(5,4,[1,2,3,4,5,6,7,8,9,10,11,12]);
plot([x0 x1],[y0 y1],[-0.5 0.5],[0 0],'linewidth',2)
hold on
plot(x1,y1,'marker','o','markerSize',25,'markerFacecolor','r')
axis([-1.5 1.5 -1.5 0.5])
grid on
file_text=sprintf('simple%05d.png',ct)
saveas (gca, file_text)% saving images generated
pause(0.01)
ct=ct+1;
hold off
end
Function code:-
This code is used to solve the given 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];
Animation Video Link:-
Errors encountered:-
Output:-
Workspace
Conclusion:-
From the animation we can see that the pendulum stops in the given interval.
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...
Planetary Gear
AIM:- To generate 3D models To assemble The generated models to from the planetary gear To do Motion Analysis on the Planetary Gear on the cases given INTRODUCTION:- Planetary Gear or Epicyclic gear is a gear system consisting of one or more outer, or planet, gears or pinions, revolving about a central sun…
18 Jul 2020 03:32 PM IST
MBD Simulation on IC Engine Valve Train
AIM:- To Model the parts To Assemble the parts created To run simulation on IC Engine Valve under the given conditions INTRODUCTION:- A valvetrain or valve train is a mechanical system that controls operation of the intake and exhaust valves in an internal combustion engine. The intake valves…
18 Jul 2020 03:29 PM IST
MBD Simulation on a Piston Assembly
AIM:- To design the different parts of the Piston Assembly. To Assemble the parts created To do Motion Analysis on the Piston Assembly and , rotary motion is provided to the crankshaft INTRODUCTION:- Piston Assembly motion analysis is study of the reciprocating motion of the piston in the cyclinder and the motion…
18 Jul 2020 03:22 PM IST
Internal Geneva Mechanism
AIM:- To create 3D models for Driver and Driven Wheels To create assemble the driver an driven wheel in order to show Internal Geneva Mechanism To do motion Study of internal geneva mechanism ( with and without Precise Contact) To make a plot of the driven wheel's angular displacement and discuss the results in different…
18 Jul 2020 03:13 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.