- #1
Tygra
- 41
- 4
- Homework Statement
- How to compute the angle of displacement
- Relevant Equations
- In Post
Hi everyone,
I am going through the book called "Numerical Methods for Engineers" and I am trying to solve for the angle of displacement of a pendulum. I am using MATLAB to do this. However, I am getting some strange results.
In the book the differential equation is:
Because this is a second order differential equation, I have converted it to two first order equations so that I can solve it using Euler's method.
So I get:
Where:
g = gravitational constant
l = Pendulum length
This is the graph
This does not look correct to me. The amplitude of the graph should decrease as the time goes on correct?
Can someone help please?
I am going through the book called "Numerical Methods for Engineers" and I am trying to solve for the angle of displacement of a pendulum. I am using MATLAB to do this. However, I am getting some strange results.
In the book the differential equation is:
Because this is a second order differential equation, I have converted it to two first order equations so that I can solve it using Euler's method.
So I get:
Where:
g = gravitational constant
l = Pendulum length
Code:
g = 9.81;
l = 0.2;
t = 0:0.1:50;
dt = t(2) - t(1);
z(1) = 0
theta(1) = 90;
for i = 1:length(t)-1
theta(i+1) = z(i)*dt + theta(i)
z(i+1) = -(g/l)*sind(theta(i))*dt + z(i)
end
This is the graph
This does not look correct to me. The amplitude of the graph should decrease as the time goes on correct?
Can someone help please?