[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Pendulum Help
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: Pendulum Help |
Date: |
Sun, 9 Oct 2011 20:42:36 -0500 |
On 9 October 2011 20:32, Nelson Chung <address@hidden> wrote:
> Dear all:
>
> Can someone tell me how to compute the motion and the period for this
> pendulum equation?
>
> x" + sinx = 0.
I suppose you mean how to solve the nonlinear IVP.
Rewrite it as
u' = v
v' = -sin(u)
So that for vector y, you have the autonomous system
y' = f(y)
where
f(y) = [y(2), -sin(y(1))].
Subject to f(0) = [a, b].
Thus define in Octave
f = @(y) [y(2), -sin(y(1))];
and pick some initial conditions,
a = [1, 0]
and use lsode to solve it, for the period t = linspace(0,10,200);
y = lsode(f, a, t);
and plot it:
plot(t, y(:,1));
HTH,
- Jordi G. H.