function pendulum1
% pendulum with damping constant c>=0  
% theta(t) = y(t) is angle from bottom position at time t
% ODE is  y'' + sin(y) = -c*y'

global c                % c is global variable 

c = 0;                  % c = 0  means NO damping
[t,y] = ode23(@f,[0,80],[pi-.1;0]);   % use @f if function is in same file 
plot(t,y(:,1))
xlabel('t'); ylabel('angle')
title('c = 0,  no damping');

c = 0.1;                % now WITH damping
[t,y] = ode23(@f,[0,80],[pi-.1;0]);
figure; 
plot(t,y(:,1))
xlabel('t'); ylabel('angle')
title('c = 0.1,  with damping');

%%%%%%%%%
function yp = f(t,y)  
global c                 % c is global variable 

yp = [ y(2) ; -sin(y(1)) - c*y(2) ];
