|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
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; y1=y(i)+h*feval(fun,x(i),y(i))
y2=y(i)+h*feval(fun,x(i+1),y1);y(i+1)=(y1+y2)/2
end
function xEulerpro
clear all;clc
[x,y]=eulerpro(@f,0,1,1,0.1)
plot(x,y)
function f=fun(x,y)
f=-y+x+1
??? Input argument "xf" is undefined.
Error in ==> haowan2 at 2
n=fix((xf-x0)/h);x(1)=x0;y(1)=y0
谢谢各位了 |
|