All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
https://youtu.be/VAj9JdQIUbw Aim To write a program that solves an equation of motion of simple pendulum with damping. Explanation The above equation is second order, To solve an ODE we are breaking into two first order equations dtheta1_dt=theta2 dtheta2_dt= -(b/m)*theta2-(g/l)*sin(theta1) clear…
Mukesh Kanna S
updated on 03 Jun 2022
Aim
To write a program that solves an equation of motion of simple pendulum with damping.
Explanation
The above equation is second order, To solve an ODE we are breaking into two first order equations
dtheta1_dt=theta2
dtheta2_dt= -(b/m)*theta2-(g/l)*sin(theta1)
clear all
close all
clc
b=0.05; %damping coefficients
m=1; %mass of the bob
l=1; %length of the string
g=9.81; %acceleration due to gravity
%initial displacement,initial velocity
theta_0=[0;3]; %angular displacementand angular velocity
t_span=linspace(0,20,300); %generate an array of 100 values between 0 t0 20 seconds
%ODE syntax
[t,results]=ode45(@(t,theta)ode_func(t,theta,b,g,l,m),t_span,theta_0);
ct=1;
for i=1:length(results)
x0=0; %coordinates for fixed point of pendulum
y0=0;
x1=l*sin(results(i,1)); %coordinates for oscillating point of pendulum
y1=-l*cos(results(i,1));
%plotting
plot([x0 x1],[y0 y1],'LineWidth',5,'color','r') %plot for string movement
hold on
plot(x1,y1,'marker','o','markerSize',20,'MarkerEdgeColor','b') %plot for bob
axis([-1.5 1.5 -2 2]) %defining the axis for the graph
pause(0.03)
M(ct)=getframe(gcf); %gathering the frames of the pendulum movement
ct=ct+1; %incrementing the counter
hold off
end
movie(M) %calling the frames
videofile=VideoWriter('secondODE.m','Uncompressed AVI')
open(videofile) %open the video
writeVideo(Videofile,M) %writing the frames in a videofile
close(videofile) %close the file
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
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...
Underbody Coating
Underbody Coating is a sprayable coating, which protects the under surface of the vehicle from corrosion. Underbody coating provides long term protection from corrosion to car's underbody. It also protects parts like internal body panels, frame rails and other inner cavities that are not physically accessible…
13 Jan 2023 02:52 PM IST
Benchmarking
Aim: To expain about Benchmarking and finding a good car for Mr.D.S.Pughazhyendhii by comparing the cars. Benchmarking :- Benchmarking is a process of measuring the performance of a company’s products, services, or processes…
13 Jan 2023 07:25 AM IST
Project - Analysis of a practical automotive wiring circuit
1) a) Genarator b) Battery c) Starter d) Ignition coil e) Ammeter f) Foot selector switch g) Breaker i) Fuse j) Current and voltage regulator k) Distributor 2) Genarator: A generator is a device that transforms mechanical energy into electrical energy, typically by electromagnetic induction via Faraday's Law.An electric…
28 Nov 2022 01:22 PM IST
Week 10- Assembly Workbench
AIM :- To create assemblies of Quick return mechanism and CV joint and to also create 2D drawing of the given assemblies in CATIA. ASSEMBLY :- Assembly modeling is a technology and method used by computer-aided design and product visualization computer software systems to handle multiple files that represent components…
30 Sep 2022 05:10 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.