function [modeulT, modeulW] = modeul_2(Fun, t0, tlast, w0, N)
%%%%%%%%%%% Runge-Kutta Modified Euler Method for Initial Value Problems %%%%%
%% 
%% Solve y'= f(t,y),   a<= t <=b,  y(a)=  alpha
%%
%% It is assumed that you have the function f(t,y) defined elsewhere 
%% as a function in a .m file
% INPUT:
% Fun   - String containing name of function m-file (enclose in '  ')
% t0    - Initial value of t.
% tlast - Last value of t.
% w0    - Initial value.
% N     - The number of steps
%
% OUTPUT:
% modeulT  - time points (column-vector).
% modeulW  - Solution column-vector per modeulT-values.
%
% The result can be displayed by: plot(modeulT, modeulW).

if nargin < 5, 
 error('Not enough arguments, enter help modeul_2 for help')
end;
% Initialization
modeulT = t0;
h = (tlast - t0)/N;
modeulW = w0;
t=t0;w=w0;

%% Step 2
for i=1:N;
 k1= h*feval(Fun,t,w);  
 w = w + (k1/2)+(h/2)*feval(Fun, t+h, w+k1); %%Step 3
 t = t0 + i*h;                      %%Step 3
 modeulT=[modeulT;t]; modeulW = [modeulW;w];               %%Step 4
end; 
