All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim: Write a program that solves the following ODE. This ODE represents the equation of motion of a simple pendulum with damping Write a program in MatlabOctave that will simulate the pendulum motion. Simulate the motion between 0-20 sec, for angular displacement=0,angular velocity=3 rad/sec…
Shaik Faraz
updated on 15 Apr 2022
Aim:
Write a program that solves the following ODE. This ODE represents the equation of motion of a simple pendulum with damping
Write a program in MatlabOctave that will simulate the pendulum motion.
Simulate the motion between 0-20 sec, for angular displacement=0,angular velocity=3 rad/sec at time t=0.
use,
L=1 metre
m=1 kg
b=0.05
g=9.81 m/s^2
When you do this you will get the position of the pendulum as a function of time. Use this information to animate the motion of the pendulum.
Theory:
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.
The second order ode of simple pendulum is defind as
where,
g = gravity in m/s2,
L = length of the pendulum in m,
m = mass of the ball in kg,
b=damping coefficient.
Now breaking down the 2nd order ode into two 1st order ode
Now we have defined θ1 and θ2.
## Code for solving the 2nd order ode of simple pendulum and simulating it ##
% First the code of the function
function[dtheta_dt] = ode_func(t,theta,b,g,l,m) % output of the function is dθ/dt
theta1 = theta(1); % θ1
theta2 = theta(2); % θ2
dtheta1_dt = theta2; % dθ1/dt = θ2
dtheta2_dt = -(b/m)*theta2 -(g/l)*sin(theta1);
dtheta_dt = [dtheta1_dt;dtheta2_dt]; % dθ/dt = [dθ1/dt; dθ2/dt]
end
clear all
close all
clc
b = 0.05;
g = 9.81;
l = 1;
m = 1;
theta_0 = [0;3]; % 0 is for displacment and 3 is for velocity
t_span = linspace(0,10,250);
[t,result] = ode45(@(t,theta) ode_func(t,theta,b,g,l,m),t_span,theta_0);
hold on
plot(t,result(:,1))
plot(t,result(:,2))
xlabel('Time')
ylabel('Displacement and Velocity')
legend('Angular displacement','Angular Velocity')
ct = 1;
for i = 1:length(result(:,1))
x0 = 0;
y0 = 0;
% co ordinates for the swinging point of the pendulum fixed to the massx1 = l*sin(result(i,1));
y1 = -l*cos(result(i,1));
figure(2)
plot([-5 5],[0 0],'color','k',LineWidth=5) % fixed support
axis([-2 2 -1.5 0.5]) % specifying the axis so it does not move for diffrent frames
hold on
plot([x0 x1],[y0 y1],'color','b')
plot(x1,y1,'marker','o','markerfacecolor','r','color','b','markersize',20)
pause (0.001)
hold off
M(ct) = getframe(gcf);
ct = ct +1;
end
movie(M)
videofile_pendulum_oscillation = VideoWriter('videofile_pendulum_oscillation.avi','Uncompressed AVI');
open(videofile_pendulum_oscillation)
writeVideo(videofile_pendulum_oscillation,M)
close(videofile_pendulum_oscillation)
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...
Project 1 : CFD Meshing for Tesla Cyber Truck
Aim: Performing topological cleanup and surface mesh on tesla cyber truck and on a wind tunnel based on selected target length values of its different components using element type as Tria, as well as appropriate selection of the volume that contains the vehicle and its surroundings with the wind tunnel for volumetric…
15 Nov 2022 04:17 AM IST
Week 5 Challenge : Surface wrap on Automotive Assembly
Aim: Perforform Topo cleanup and delete unwanted surfaces for Surface wrap. After Topo cleanup, Merge all 3 models and perform surface wrap. Target length for Wrap = 3 mm 1. Engine: 2. Gear box: 3. Transmission: Procedure: 1. Topo Cleanup : (Engine, Transmission & Gear Box)…
10 Nov 2022 08:22 AM IST
Week 4 Challenge : CFD Meshing for BMW car
Aim: To perform topological clean-up, and carry out the surface meshing of a BMW M6 car model and create a wind tunnel surrounding the same. Objectives: 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…
07 Nov 2022 11:33 AM IST
Week 3 Challenge : CFD meshing on Turbocharger
Aim: Performing CFD meshing on Turbocharger using ANSA Objective: For the given model, check for the geometrical errors to make appropriate volumes. Create and assign PIDs as shown in the video. Perform surface mesh with the given target lengths as per PIDs. Blade stage-1 = 1 mm Blade stage-2 = 1 mm Impeller = 2 mm…
03 Nov 2022 08:06 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.