function xEulerpro
clear all;clc
[x,y]=eulerpro(@fun,0,1,1,0.1)
plot(x,y)
function f=fun(x,y)
f=y+x+1
%------------------------
function [x,y]=eulerpro(fun,x0,xf,y0,h)
n=fix((xf-x0)/h);x(1)=x0;y(1)=y0
for i=1:(n-1)
x(i+1)=x0+i*h; a=y(i)+h*feval(fun,x(i),y(i))
b=y(i)+h*feval(fun,x(i+1),a);y(i+1)=(a+b)/2
end
以上是解一个微分方程的程序