All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Solving Second Order ODES AIM: To simulate the pendulum motion and to use the second order ode as a function to determine the plots of angular displacement and velocity with respect to time using matlab.to create a animation of it. OBJECTIVE: Write a program to solve the second ode equation. To Determine the function to…
Deepak Nambiraja S.K
updated on 13 Oct 2020
Solving Second Order ODES
AIM:
To simulate the pendulum motion and to use the second order ode as a function to determine the plots of angular displacement and velocity with respect to time using matlab.to create a animation of it.
OBJECTIVE:
Theory:
In Engineering, ODE is used to describe the transient behavior of a system. A simple example is a pendulum
A Simple pendulum consists of string with a length (l)which is fixed at one end and the other end is free.the freeend is fixed with ball with constant mass(m).From this motion we can undersatnd the newton second law of motion. due to motion of ball with respect to time we can determine angular displacement and velocity. this motion also decribes the motion of damper ,spring and mass in were the simple pendulum works.
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" with respect to time.
EQUATION:
This ODE represents the equation of motion of a simple pendulum with damping
In above equation we have to include the values of gravity,length of the string,damping coefficient,mass of the ball in kg.
g = gravity in m/s2,
L = length of the pendulum in m,
m = mass of the ball in kg,
b=damping coefficient.
value given to solve the ode function are
use,
L=1 metre.
m=1 kg.
b=0.05.
g=9.81 m/s2.
the given values for simple pendulum and solving the second order differential equation are programmed or coded by matlab. for solving this equation we required in-build code known as ode 45 is used and this ode function use the values of length,damping coeeficient ,gravity,mass of the ball. for deriving or converting the second order differential into first order differential . matlab ode function is used
Function used in 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)*sind(theta1);
[dtheta_dt]=[dtheta1_dt;dtheta2_dt];
end
this value derived from the function is used for converting second order differential into first order differential.thif function include to the main code for deriving the plots of angular displacement and angular velocity.
Main Code
clear all
close all
clc
b=0.05;
g=9.81;
l=1;
m=1;
%inital condition
theta_0=[0,3]
%time point
t_span= linspace(0,20,500);
%solve ode
[t,results]=ode45(@(t,theta)ode_func(t,theta,b,g,l,m),t_span,theta_0);
figure(1)
plot(t,results(:,1));
hold on
plot(t,results(:,2));
ylabel('displacement/angular velocity');
xlabel('time');
legend('displacement','velocity')
ct=1;
for i=1:length(t_span)
angle=(results(:,1))
ANGLE=angle(i)
figure(2)
% coordinates
x0=0;
y0=1;
x1=1*sin(ANGLE);
y1=-l*cos(ANGLE);
plot([x0 x1],[y0 y1],'linewidth',3);
hold on
line([-2,2],[1,1],'linewidth',3);
plot(x1,y1,'.','markersize',30,'markerfacecolor','r');
hold off
grid on
axis([-3 3 -3 3])
M(ct)=getframe(gcf);
ct=ct+1;
end
movie(M)
videofile = VideoWriter('simple_pendulum.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Code Explanation:
clear all,close all and clc removes and gives us a clean sheet.the initial values are given for solving the ode which are damping coefficient ,gravity , length of the string and mass. as the mass as constant.inital condition for theta is given with angular displacement and velocity.which is(thetha_0=[0,3]).for solving the second order ode function a in-build code is used (ode45(@(t,theta)ode_function(t,theta,b,g,l,m),t_span,theta_o)).the angular displacement and velocity is determined with respect to time .so %time point is used with the values(t_span=linspace(0,20,500)).by values of displacement and velocity we can plot the values of the results with respect to time.
plotting values of ode function is saved in figure(1).
figure(1): plots of angular displacemnt and velocity with respect to time
After plotting the results of the ode function .Animation of the simple pendulum have to be constructed or created using matlab code .in this code animation figures are provided with frame.from those frame movie is created.
figure(2): Image Of animated simple pendulum.
video of the animation is provided with you tube link simple pendulum simulation
conculsion
The program sucessfully converted second ode into first ode using ode function .the simulation and animation of the simple pendulum is also created sucesfullyusing matlab.
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...
Wiring harness design in CATIA V5 - 3D modeling Week 2 Challlenge
AIM: Defining the connector & connector clip as a electrical component using electrical design workbench.Interpret necessary properties to Connectors & Clip. Connector: connector are responsible to make contact between wiring harness and components or between two different wiring harness assemblies by offering…
02 Feb 2022 01:10 PM IST
Design of backdoor
AIM: Design a back door using appropriate design methodology with provided input styling surface and intent necessary reinforcements and embosses. Input styling surface: input is provided with two panels upper half and lower half and those two panel are considered as inputs for creating inner and outer…
30 Dec 2021 11:34 AM IST
Roof challenge
AIM: To Develop the essential flanges and reinforcements with Provided appropriate dimensions and check for Draft analysis with the creation of a roof ditch area tool opening angle is only 3 degrees. To perform a curvature study on the roof and to determine a calculations to obtain the position of the Bow-roofs.…
03 Dec 2021 10:25 AM IST
Fender Design Challenge
AIM: The primary Function of fender: Fender is the American English term for the part of an automobile, motorcycle or other vehicle body that frames a wheel well (the fender underside). Its primary purpose is to prevent sand, mud, rocks, liquids, and other road spray from being thrown into the air by the rotating…
01 Nov 2021 08:18 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.