func6p11.m
资源名称:数值分析课程设计.zip [点击查看]
上传用户:zhdd911129
上传日期:2007-05-11
资源大小:722k
文件大小:1k
源码类别:
matlab例程
开发平台:
Matlab
- %func6p11.m常微分初值问题
- s=0,t=1,n=100,y1=1
- a=linspace(s,t,n)
- x=t-s
- h=(t-s)/n
- %Euler Rule
- for i=1:n-1
- y11=y1+x/n*sub6p11(a(i),y1)
- y1=y1+x/n/2*(sub6p11(a(i),y1)+sub6p11(a(i+1),y11))
- disp(i)
- end
- %R-K Rule
- y1=1
- for i=1:n-1
- k1=sub6p11(a(i),y1)*h
- k2=sub6p11(a(i)+h/2,y1+k1/2)*h
- k3=sub6p11(a(i)+h/2,y1+k2/2)*h
- k4=sub6p11(a(i)+h,y1+k3)*h
- y1=y1+(k1+2*k2+2*k3+k4)/6
- disp(i)
- end
- %True Value:y(1)=0.60995168498111510516376506679627, y(0.5)=0.73204284797281271034681566467062
- %Euler Rule:y(1)=0.61296795390463,y(0.5)=0.73598135556071
- %R-K Methom:y(1)=0.61295629484976,y(0.5)=0.73597167736700,R-K方法略优于Euler