A program to simulate the transient behaviour of a simple pendulum and to create an animation of its motion Using MATLAB
AIM Simulation of the transient behaviour motion
INTRODUCTION
GOVERNING EQUATION: A simple pendulum consists of a mass m hanging from a string of length Land fixed at a pivot point P. When displaced to an initial angle and released, the pendulum will swing back and forth with the periodic motion. When the motion of a pendulum reduces due to an external force, the pendulum and its motion are damped. These periodic motions of gradually decreasing amplitude are damped simple harmonic motion.
By applying Newton\'s second law for rotational systems, the equation of motion for the pendulum can be obtained:
θ = angular displacement
t = time
b = damping coefficient, 0.05
m = mass, 1 kg
I = length of pendulum, 1 m
g = gravity: 9.81 m/s^2
equilib
positio
time domain= (0,20): in seconds
Initial conditions, at t=0
θ =0 and ω=3 rad/sec
MATLAB PROGRAM
%to simulate motion of pendulum
clear all
close all
clc
%given constants
l=1;
m=1;
b=0.05;
g=9.81
%initial conditions
theta_0=[0,3];
t_span=linspace(0,20,200);
%solving ODE
[t,results] = ode45(@(t,theta) ode_func(t,theta, b,g,l,m),t_span,theta_0);
%ploting displacement and velocity vs time
figuer(1)
plot(t_span,results,\'linewidth\',2);
grid on;
title(\'Pendulum damping effect\');
xlabel(\'Time(sec)\');
legend(\'Ang.Displacement (rad.)\',\'velocity (m/s)\');
%simulation of pendulum
ct=1;
figure(2)
for i=1:lenth(t_span)
fi=results(i,1);
plot([-0.5,0.5],[0.0],\'color\',\'r\',\'linewidth\',7);
hold on;
plot([0,0],[-1,0.1],\'--\',\'linewidth\',2);
hold on;
plot(sin(fi),-cos(fi),\'o\',\'markerfacecolor\',\'b\',\'markersize\',40);
hold on;
plot([0,sin(fi)],[0,-cos(fi)],\'linewidth\',8);
axis([-1,1,-1.5,0.25]);
grid on;
title(\'pendulam swing simulator\');
pause(0.00008);
M(ct)=getframe(gcf);
hold off;
ct=ct+1;
end
movie(M);
videofile=videowriter(\'pendulum_stimulation.avi\',\'uncompressed AVI\');
open(videofile);
writevideo(videofile,M);
close(videofile)
FUNCTION USED
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/1)*sin(yheta1);
dtheta_dt = [dtheta1_dt;dtheta2_dt];
end
ERROE FACED
No Error Found
OUTPUT
Animated Link
Conclusion
tp simulated the transient behaviour of simple pendulum second order are ODE are solved using MATLAB and Animation od motion pendulum motion was created to describe the damping effect