chap8.m

来自「插值matlab源程序,附使用说明,包括拉各朗日插值,牛顿插值,及示例」· M 代码 · 共 41 行

M
41
字号
ydot_fun=inline('x+y','x','y');
%[x,y]=euler_r(ydot_fun, 0,1,0.02, 5)
[x,y]=Runge_Kutta4s(ydot_fun, 0,1,0.1, 10)
[x,y]=Adams(ydot_fun, 0, 1, 0.1, 10)

ydot_fun=inline('[y(1)+0.1*y(2); 0.1*y(1)-y(2)]','x','y');
[x,y]=Runge_Kutta4s(@lorenzeq, 0,[1; 1; 1], 0.01, 5e3);
plot3(y(1,:), y(2,:), y(3,:));
%[t,x]=ode45(ydot_fun,[0,1],[1,-1]);
%figure;plot(x(:,1), x(:,2))

odefun=inline('[-0.01*y(1)-99.99*y(2); -100*y(2)]','x','y');
[x,y]=ode15s(odefun, [0 100], [2 1]);[x';y']
[x,y]=ode45(odefun, [0 100], [2 1]);[x';y']
[x,y]=Adams_S(odefun, 0, [2;1], 0.01, 10)
odefun=inline('[-0.01*y(1)-99.99*y(2); -100*y(2)]','x','y');
[x,y]=Runge_Kutta4s(odefun, 0, [2;1], 0.01, 10);

odefun=inline('[y(2); -y(2)./x+(((1/2)./x).^2-1)*y(1)]','x','y');
options=odeset('reltol',1e-4, 'abstol', 1e-6, 'outputfcn', 'odeplot');
[x,y]=ode23(odefun, [pi/2 pi], [2 -2/pi],options);

odefun=inline('[2*x(1)-x(1)*x(2); -x(2)+x(1)*x(2)]','t','x');
options=odeset('reltol',1e-4, 'abstol', 1e-6, 'outputfcn', 'odephas2');
hold on 
axis([0 4 0 6]); xlabel('x'); ylabel('y');
[t,x]=ode45(odefun, [0 5], [1 0.3],options);
[t,x]=ode45(odefun, [0 5], [1 0.5],options);
[t,x]=ode45(odefun, [0 5], [1 0.7],options);
[t,x]=ode45(odefun, [0 5], [1 0.9],options);
[t,x]=ode45(odefun, [0 5], [1 1.1],options);
hold off

[t,x]=ode45(@Lanch, [0 36], [0, 21500]);
plot(t(58:125), x(58:125,1));

odefun=inline('x*y^(1/3)','x','y');
[x,y]=euler_f(odefun, 1, 1, 0.01, 100);
plot(x,y,'o-', x, ((x.^2+2)./3).^(3/2),'o-');

    

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?