All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM:- To solve a second order differential equation using MATLAB INTRODUCTION:- Solving a second order differential equation by breaking down into a set of first order differential equation in MATLAB EQUATION:- d2θdt2+bm⋅dθdt+gl⋅sinθ=0 Where, g = gravity L = length of the string in ‘m’…
Tushar Singh
updated on 27 Aug 2020
AIM:- To solve a second order differential equation using MATLAB
INTRODUCTION:- Solving a second order differential equation by breaking down into a set of first order differential equation in MATLAB
EQUATION:-
d2θdt2+bm⋅dθdt+gl⋅sinθ=0
Where,
g = gravity
L = length of the string in ‘m’
m = mass of the bob
b = damping coefficient
θ = angle made by the string
Assume
θ=θ1
dθdt=θ2
d2θdt2=d2θ1dt2=ddt(dθ1dt)=dθ2dt
d2θ1dt2+bm⋅dθ1dt+gl⋅sinθ1=0
dθ2dt+bm⋅θ2+gl⋅sinθ1=0
ODE FUNCTION CODE:-
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];
end
MATLAB CODE FOR SOLVING ODE:-
b=0.05;
g=9.81;
l=1;
m=1;
%initial conditions
theta_0=[0;3];
%time points
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));
%For creating animation of pendulum
theta=results(:,1);
ct=1;
for i=1:length(results)
THETA=results(i,1);
x=0
y=0
x0=l*sin(THETA);
y0=-l*cos(THETA);
figure(2)
hold on
plot([x,x0],[y,y0],'linewidth',2);
plot(x0,y0,'-o','markersize',20);
axis([-2 2 -2 2]);
pause(0.005);
M(ct)=getframe(gcf)
ct=ct+1;
clf();
end
movie(M);
videofile=VideoWriter('pendulumn_animation','Uncompressed avi');
open(videofile);
writeVideo(videofile,M);
close(videofile);
GRAPH OF ODE FUNCTION:-
ERRORS FACED:-
I didn't used the ')' symbol in 34th line
Used y=l*cos(theta) instead of y=-l*cos(theta)
CONCLUSION:- Here we have written a code to simulate the motion of pendulum using a second order differential equation using MATLAB
LINK FOR MOTION OF PENDULUM:-
https://youtu.be/03GBK0Gytpw
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...
Week 3 - 2D meshing for Sheet metal
Objective:- For the given Hood model, Take the mid surface for all the components after checking the geometrical errors and mesh the mid surface with the given element Quality criteria.S. No Quality Criteria Value 1Target/Average length 52Minimum Length 23Maximum Length 74Aspect 35Warpage156Skewness457Jacobian 0.78Minimum…
19 Mar 2023 03:12 PM IST
Project 1 : CFD Meshing for Tesla Cyber Truck
Objective:- For the given model, check and solve all geometrical errors and Assign appropriate PIDs. Perform meshing with the suitable Target length and element Quality criteria. Target lengths for the different parts of a model can be decided by your own. Finer mesh will give good results and will compromise with the…
03 Oct 2022 02:19 PM IST
Week 4 Challenge : CFD Meshing for BMW car
Objective:- For the given model, check and solve all geometrical errors on half portion and Assign appropriate PIDs. Perform meshing with the given Target length and element Quality criteria. After meshing the half model, Do symmetry to the other side.Target lengths for the different parts of a model are as follow:Body…
29 Sep 2022 03:22 PM IST
Week 5 Challenge : Surface wrap on Automotive Assembly
Objective:- For the given models, check for the geometrical errors and delete surfaces which are unwanted for Surface wrap as shown in the videos. After clearing geometry, Merge all 3 models and perform surface wrap. Target length for Wrap = 3 mmProcedure:- Load all the three models in ANSAENGINETRANSMISSIONGEAR BOXDeleting…
28 Aug 2022 03:04 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.