%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myEuler(delta_t,subwindow)
%-----------------------------------------
% Matlab script to solve 
%   x' = a * x
% by Euler's method 
%
% input values:
%     delta_t: timestep
%     subwindow: which subwindow the plot will go (1-4)
% 
% time interval: [ 0 , t_end ]
% time step:     delta_t
%
% initial condition: x(0) = x_init
%
% (Hans De Sterck, AMATH341/CS371, Fall 2004)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% define the problem
a=-5.;
t_end=4.;
x_init=1.;

% determine how many discrete points there are and allocate arrays for x and t
n_points=round(t_end/delta_t);
x=zeros(n_points+1,1);
t=zeros(n_points+1,1);

% the initial condition
% note: in Matlab, arrays are indexed starting from index 1 !
x(1)=x_init;
t(1)=0;

% THIS IS WHERE YOU HAVE TO IMPLEMENT THE EULER METHOD...
% (for instance, use a for loop to loop over the discrete points)


% plot the numerical and the exact result
% open a new plotting window
figure(1)
subplot(2,2,subwindow)
% plot the t,x vectors
plot(t,x,'-+')
hold on
% plot the exact solution
plot(t,x_init*exp(a*t),'r')
title(strcat('delta t = ',num2str(delta_t)))
hold off

%-----------------------------------------
