forked from burakbayramli/books
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ieuler.m
32 lines (30 loc) · 890 Bytes
/
ieuler.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function [tz,uz] = ieuler(f,t0,u0,tf,h,c)
%
% [tz,uz] = ieuler(f,t0,u0,tf,h,c)
%
% Uses Improved Euler method to solve a first order ODE
% Plots components of solution in Figure #1
% In 2-D case, also plots phase plane trajectory in Figure #2
%
% Input arguments:
%
% f - string name of function on right hand side of ODE: u' = f(t,u)
% note: f must return a column vector
% t0 - initial time
% u0 - initial data u(t0) --- column vector
% tf - final time or, if vector, list of times to evaluate solution.
% h - step size
%
% Optional arguments:
%
% c - color for plot
%
% Output:
%
% tz - times for evaluation of function as specified by tf, or,
% if tf is a scalar, all mesh points
% uz - value of solution at times tz.
%
% See also NUMODE, NEULER, MIDP, RK4, NEULERF, IEULERF, MIDPF, RK4F
%
[tz,uz] = numode('ieulerf',f,t0,u0,tf,h,c);