Você está na página 1de 8

Part 2

1. Using the second-order differential equation of the pendulum with respect


to time:
'' =

mgr
sin
( I G +m r 2)

converting it into a system of first-order differential equations returns:


'1= 2
'

2 =

mgr
sin 1
( I G +m r 2)

Substituting the values of m = 0.1270kg, r = 0.1778m,

IG

= 1.2E-3, g =

9.81 m/s returns:


'

1= 2
'

2=42.478 sin 1
1 is the displacement , 2 is the velocity , 1 ( 0 )= 0 (initial displacement ) , 2 ( 0 )=0
2. After collecting the data in the experiment, we used a fourth order rungekutta method to create a function that will approximate the differential
equation solution for displacement x(:,1) and velocity x(:,2).
The following code was used for this assignment:
function [x,t] = runge_kutta(tmax,IC,h)
x(1) = IC(1);
v(1) = IC(2);
t = 0:h:tmax;
for i = 1:length(t)-1
dx1 = h*v(i);
dv1 = h*ode_pendulum(x(i));
dx2 = h*(v(i) + 1/2*dv1);
dv2 = h*ode_pendulum(x(i)+1/2*dx1);
dx3 = h*(v(i) + 1/2*dv2);
dv3 = h*ode_pendulum(x(i)+1/2*dx2);
dx4 = h*(v(i) + dv3);
dv4 = h*ode_pendulum(x(i)+dx3);
x(i+1) = x(i) + 1/6*(dx1 + 2*dx2 + 2*dx3 + dx4);
v(i+1) = v(i) + 1/6*(dv1 + 2*dv2 + 2*dv3 + dv4);
end
end

The function ode_pendulum is defined as followed:


function d2xdt2 = ode_pendulum(x)
m = 0.127;
r = 0.1778;
I = 0.0012;
g = 9.81;
d2xdt2 = -m*g*r/(I+m*r^2)*sin(x);
end

The following five graphs show the displacements of the 5 initial angles
tested:
The following code was used:
IC = [-11,0;-21,0;-34.5,0;-54,0;-65,0]*pi/180;
for j = 1:5
[x,t] = runge_kutta(8,IC(j,:),0.1);
x_degrees = x.*180/pi
figure
plot(t,x_degrees);
end

With the step size specified, the graphs are not smooth approximations of

the original data:


The original data also includes a decay of amplitude over time, due to the
force due to friction throughout the pendulum. The following code was used
for this plot:
% Load Data
data_0_15 = load('C:\Users\Arun\Documents\MATLAB\Lab 4\0-15\d1.mat');
theta_0_15 = pi/180*data_0_15.ans(2,:);
t_0_15 = data_0_15.ans(1,:);
%Plot Data
figure
plot(t_0_15,theta_0_15);
title('Angular Displacement vs. Time of Pendulum from Equilibirum Position')
xlabel('Time (s)')
ylabel('Theta (Degrees)')

3. For the velocity analysis, we can use the same runge-kutta method, but
output angular velocity (v) instead of angular displacement (x):
IC = [-11,0;-21,0;-34.5,0;-54,0;-65,0]*pi/180;
for j = 1:5
[x,v,t] = runge_kutta(8,IC(j,:),0.1);
figure
plot(t,x_degrees);
title('Angular Displacement vs. Time of Pendulum from Equilibirum Position')
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')
end

Velocit
y

Velocit
y

Velocit
y

Velocit
y

Velocity

Similarly, we can take derivatives of the original data and plot the angular
velocities of the pendulum, here is the velocity of the first initial angle. This
data was smoothed with a moving average with window size of 7:
% Load Data
data_0_15 = load('C:\Users\Arun\Documents\MATLAB\Lab 4\0-15\d1.mat');
theta_0_15 = pi/180*data_0_15.ans(2,:);
t_0_15 = data_0_15.ans(1,1:3998);
v_0_15 = diff(theta_0_15);
for i=1:length(v_0_15)-6
v_0_15_smooth(i) = 1/7*(v_0_15(i) + v_0_15(i+1) + v_0_15(i+2) + v_0_15(i+3) +
v_0_15(i+4) + v_0_15(i+5) + v_0_15(i+6));
end
%Plot Data
figure
plot(t_0_15,v_0_15_smooth);
title('Angular Velocity vs. Time of Pendulum from Equilibirum Position')
xlabel('Time (s)')
ylabel('Angular Velocity (rad/s)')

Comparing the data to the numerical solver, one can see that the numerical
simulation simulates the period of the velocity function quite well, however,
it has a low resolution overall when precision is important to the problem.
However, this can be improved by increasing the step size from h = 0.1 to
h= 0.01.
The following graph shows the velocity of the first initial displacement with a
step size of t = 0.01s, and shows considerable resolution improvements over
the graphs on the previous page.

Você também pode gostar