% Differenzialgleichungen:

phip   = inline ('omega','omega') ;
omegap = inline ('-faktor*sin(phi)','t','phi','omega','faktor') ;

pl     = 1 ;                          % Pendellaenge
g      = 9.81 ;                       % Erdbeschleunigung
faktor = 1.5*g/pl ;

t0 = 0 ;  phi0 = pi/2 ; omega0 = 0 ;  % Anfangswerte
tEnd = 1   ;                          % Ende des Integrationsintervalls
n    = 100 ;                          % Anzahl der Integrationsschritte
dt   = (tEnd - t0) / n ;

t = t0 : dt : tEnd    ;
phi   = zeros (n+1,1) ;
omega = zeros (n+1,1) ;

% Euler-Cauchy-Algorithmus -------------------------------------------- 
phi(1)   = phi0   ;
omega(1) = omega0 ;

for i=1:n
    phi  (i+1) = phi  (i) + dt * phip   (omega(i)) ;
    omega(i+1) = omega(i) + dt * omegap (t(i),phi(i),omega(i),faktor) ;
end
% Euler-Cauchy-Algorithmus -------------------------------------------- 

phiMin=min(phi)
omegaMax=max(abs(omega))              % Extremwerte ---> Command Window
plot (t,phi)                          % Graphik-Ausgabe phi(t)
