Example of the Euler Method in 2D
We will use the Euler method to solve the damped pendulum equation written as a system
for initial conditions , , and .
% Set up initial conditions and parameters
% Loop through and run the Euler method
x(k+1) = x(k) + h * y(k);
y(k+1) = y(k) + h * (-gamma*y(k)-sin(x(k)));
Plot the solution in the phase plane