func6ok.m
上传用户:zhdd911129
上传日期:2007-05-11
资源大小:722k
文件大小:1k
源码类别:

matlab例程

开发平台:

Matlab

  1. s=0,t=1,n=100,y1=1
  2. a=linspace(s,t,n)
  3. x=t-s
  4. h=(t-s)/n
  5. %Euler Rule
  6. for i=1:n-1
  7.     y11=y1+x/n*sub6p11(a(i),y1)
  8.     y1=y1+x/n/2*(sub6p11(a(i),y1)+sub6p11(a(i+1),y11))
  9.     disp(i)
  10. end
  11. %R-K Rule
  12. y1=1
  13. for i=1:n-1
  14.     k1=sub6p11(a(i),y1)*h
  15.     k2=sub6p11(a(i)+h/2,y1+k1/2)*h
  16.     k3=sub6p11(a(i)+h/2,y1+k2/2)*h
  17.     k4=sub6p11(a(i)+h,y1+k3)*h
  18.     y1=y1+(k1+2*k2+2*k3+k4)/6
  19.     disp(i)
  20. end
  21. %True Value:y(1)=0.60995168498111510516376506679627, y(0.5)=0.73204284797281271034681566467062
  22. %Euler Rule:y(1)=0.61296795390463,y(0.5)=0.73598135556071
  23. %R-K Methom:y(1)=0.60997504144240,