Untitled
By: a guest | Mar 22nd, 2010 | Syntax:
None | Size: 0.19 KB | Hits: 69 | Expires: Never
function [t x] = modeuler(T,N)
f = @(t,x) 2*x/(t+1)-x^2/(t+1)^3;
h = T/N;
t = 0:h:T;
x = [1 zeros(1,N)];
for n = 1:(N)
x(n+1)=x(n)+h*f(t(n)+h/2,x(n)+h/2*f(t(n),x(n)));
end
end