0% found this document useful (0 votes)
154 views3 pages

Simple Harmonic Motion and Pendulums

This document discusses using MATLAB to solve differential equations describing simple harmonic motion, such as that of a pendulum. It presents the differential equation that describes a damped, driven pendulum and explains how to use the ode45 routine to solve second-order differential equations by converting them to a system of first-order equations. The document provides an example of solving the equation for undamped, unforced simple harmonic motion and instructs the reader to investigate different cases of damped, driven motion using ode45.

Uploaded by

Adimasu Ayele
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
154 views3 pages

Simple Harmonic Motion and Pendulums

This document discusses using MATLAB to solve differential equations describing simple harmonic motion, such as that of a pendulum. It presents the differential equation that describes a damped, driven pendulum and explains how to use the ode45 routine to solve second-order differential equations by converting them to a system of first-order equations. The document provides an example of solving the equation for undamped, unforced simple harmonic motion and instructs the reader to investigate different cases of damped, driven motion using ode45.

Uploaded by

Adimasu Ayele
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Exercise 10: Simple Harmonic Motion and Pendulums

solving differential equations


Many of the equations we meet in physics involve derivatives and hence are differential
equations. An important example is Newtons second law which is a second order
differential equation since it involves acceleration (the second time derivative of
displacement. MATLAB is equipped with several routines to solve differential equations.
The damped Driven Pendulum:
The angular displacement (t) in such a pendulum satisfies the second order differential
equation:
Eq. 1
where k is called the damping ratio, f is the amplitude and the angular frequency of the
forcing term. For simplicity we have set g/l=1 in the equation above, where g is the
gravitational acceleration and l the length of the pendulum.
For small amplitude motion we can replace sin() by to obtain the equation for damped
forced simple harmonic motion:

In MATLAB we can solve such an equations by using the ode45 routine, which is invoked
by the command ode45(@function,t,u0), where function defines the right side of
the differential equation you would like to solve (see example below), t a vector specifying
the interval of integration, and u0 a vector of initial conditions.
Many more differential equation solvers are available in MATLAB, and you can find a
description of these in the Users Guide Mathematics Calculus. Most of the
information you need to know to solve this exercise is however presented in the example
below.
As an example, we solve the case of undamped unforced simple harmonic motion.

with the initial conditions (0)=0.1, (0)=0.

27
v2.11

MATLAB Ordinary Differential Equation (ODE) solvers accept only first-order differential
equations. To use the solvers with higher-order ODEs, you must rewrite each equation as
an equivalent system of first-order differential equations, in this case:

Then we need to define a function handle to describe the system of two first-order
differential equations in and . We do this in a separate function file, which we call e.g.
UnUnfSH.m:
% Function handle for ODE of an unforced, undamped, simple
% harmonic oscillator
function du = UnUnfSH(t,u)
theta = u(1);
theta_prime=u(2);
du = zeros(2,1);
% first equation in theta
du(1) = theta_prime;
% second equation
du(2) = - theta;
end

Then we define a vector of initial conditions u0=[0.1 0], and a vector specifying the
interval of integration t = 0:0.1:100;
Now all we need to do is run the ode45 command, which will give as output the solution
of the differential equation in the specified t domain (i.e. (t) and (t) ).
[T, SOL] = ode45(@UnUnfSH, t, u0);

28
v2.11

We can then plot (t) by selecting the first column in the solution array using e.g.
plot(T,SOL(:,1)), and obtain the following figure:

Try changing initial conditions and domain of integration to familiarise with the command.

You should now use the ode45 command to investigate damped driven simple
harmonic motion in the following situations:
A. damping but no forcing term, show both under-, over- and critical damping (k < 1, k > 1,
k=1)
B. forcing in each damping case away from resonance (choose f=0.1 and =1.2).
C. the damped forced pendulum (Eq. 1) with k=0.05, f=1.5, and =1.1 with initial
conditions (0)=0.1, (0)=0 and (0)=0.101, (0)=0, both plotted on the same graph.
Note the effect on the solution of a small change in the initial conditions. This extreme
sensitivity to initial conditions is the signature of chaos.

When the exercise is complete save your work and show it to a


demonstrator.

29
v2.11

You might also like