Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 22nd, 2010 | Syntax: None | Size: 0.19 KB | Hits: 69 | Expires: Never
Copy text to clipboard
  1. function [t x] = modeuler(T,N)
  2.         f = @(t,x) 2*x/(t+1)-x^2/(t+1)^3;
  3.         h = T/N;
  4.         t = 0:h:T;
  5.         x = [1 zeros(1,N)];
  6.         for n = 1:(N)
  7.                 x(n+1)=x(n)+h*f(t(n)+h/2,x(n)+h/2*f(t(n),x(n)));
  8.         end
  9. end