All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim : Solve the Second order ODE using Matlab Programming and create a Animation of pendulam and its motion. Given Problem Statement: In given Equation g = gravity (m/s2) = 9.81 m= mass of ball (kg) = 1 l = length of the pendulum…
Rehaman Khan Pathan
updated on 13 Oct 2020
Aim : Solve the Second order ODE using Matlab Programming and create a Animation of pendulam and its motion.
Given Problem Statement:
In given Equation
g = gravity (m/s2) = 9.81
m= mass of ball (kg) = 1
l = length of the pendulum (m) = 1
b =damping coefficient = 0.05
Simulate the motion between 0-20 sec, for angular displacement=0,angular velocity=3 rad/sec at time t=0.
solving 2nd order ODE:
Assuming theta = theta1
diffrentiate dtheta_dt = dtheta1_dt = theta2
d^2theta_dt^2 = d^2theta1_dt^2 = dtheta2_dt
d^2theta_dt^2 + (b/m)dtheta_dt +(g/l)*sin(theta) = 0
d_theta2_dt + (b/m)theta2 +(g/l)sintheta1 = 0
dtheta1_dt = theta2
dtheta2_dt = -(b/m)*theta2 - (g/l)*sin(theta1)
Software Used : MATLAB
Program:
clear all
close all
clc
% Input variables
% b = daming
% m = mass
% g = gravity
% l =length
b = 0.05;
g = 9.81;
l = 1;
m = 0.1;
% Intial Condition
theta_0 = [0;3];
% time points
t = linspace(0,10,100);
% solve ODE
[t,results] = ode45(@(t,theta)ode_func(t,theta,b,g,l,m),t,theta_0);
figure(1)
hold on
plot(t,results)
xlabel('time')
ylabel('theta & velocity')
legend('theta','velocity')
hold off
disp = results(:,1);
vel = results(:,2);
ct =1;
for i =1:length(disp)
x0 = 0;
y0 = 0;
x1 = l*sin(disp(i));
y1 = -l*cos(disp(i));
figure(2)
plot([x0,x1],[y0,y1],'linewidth',3,'color','b')
hold on
plot(x1,y1,'marker','o','markersize',15,'markerfacecolor','g')
axis([-1.5 1.5 -1.5 1])
plot([-1.5 1.5],[0 0],'linewidth',3)
pause(0.05)
hold off
M(ct) = getframe(gcf);
ct = ct+1;
end
movie(M)
videofile = VideoWriter('pendulum avi','uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)
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*theta2/m) - (g*sin(theta1)/l)
dtheta_dt = [dtheta1_dt; dtheta2_dt];
end
Output Plot:
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...
Independent Research Project
Aim: To calculate the estimated force acting on the valve during the different operating conditions. Given Problem Statement: This estimated force should be above the target cracking force (opening force) of the valve which is 300N. The solid geometry will be provided, which can be simplified to extract fluid…
26 Jul 2021 04:13 PM IST
Week 4 Challenge : CFD Meshing for BMW car
Aim: 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. Software Used: ANSA Pre-processor Given data: Target lengths for the…
11 May 2021 11:42 AM IST
Week 5.1 - Mid term project - Solving the steady and unsteady 2D heat conduction problem
Aim: Solving the 2D heat conduction problem for steady and transient state using various iterative techniques (Jacobi, Gauss seidel and Successive over relaxation methods) using Matlab Given that: Top Boundary = 600 K Bottom Boundary = 900 K Left Boundary = 400 K Right Boundary = 800 K Your absolute error criteria…
02 Apr 2021 04:03 AM IST
Week 3 Challenge : CFD meshing on Turbocharger
Aim: Check the geometrical errors to make appropriate volumes and assign the PID's. Also perform the surface mesh on Turbocharger. Software used: ANSA Pre-processor Theory: A turbocharger is a device fitted to a vehicle’s engine that is designed to improve the overall efficiency and increase performance. This is…
23 Mar 2021 10:47 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.