clear;
//Parameters
m = 1.0; // mass of the pendulum
c = 1.5; // damping coefficient
L = 4.5; // length of the pendulum
g = 9.81; // acceleration of gravity
// x=x(1) = angle, y=x(2) = angular velocity
function dx = PEND(t,x)
dx(1) = x(2);
dx(2) = -g/L * sin( x(1) ) - c/m/L * x(2);
endfunction
// The time range and step for calculation
Tin = 0;
Tout = 40;
Tstep = 0.01;
t = Tin:Tstep:Tout;
// The initial values
x10 = 1.2;
y10 = 1.5;
X10 = [x10; y10];
X1 = ode(X10,0,t,PEND);
x20 = -0.6;
y20 = -1.8;
X20 = [x20; y20];
X2 = ode(X20,0,t,PEND);
x30 = -1.3;
y30 = -1.5;
X30 = [x30; y30];
X3 = ode(X30,0,t,PEND);
clf;
plot(X1(1,:), X1(2,:), 'r')
plot(X2(1,:), X2(2,:), 'b')
plot(X3(1,:), X3(2,:), 'g')
xlabel('x')
ylabel('y')