seajisi.m

来自「自己编的四节龙格琨塔程序」· M 代码 · 共 29 行

M
29
字号
clear,clf,shg
%Set the definied time
%ts=0:0.05:.5;
%
ts=0:0.1:1.6;
n=length(ts);
x0=[0 0];
a=20;b=40;c=15;
%
%a=35;b=40;c=15;
%
opt=odeset('RelTol',1e-6,'AbsTol',1e-9);

%[t,x]=ode45(@jisi,ts,x0,[],a,b,c);
%
[t,x]=ode45(@jisi,ts,x0,opt,a,b,c);
%exact solution x1=c
y1=a*t;

%output t,x(t),y(t) and draw x(t),y(t)
[t,x,y1]
plot(t,x),grid,gtext('x(t)','FontSize',16),
gtext('y(t)','FontSize',16),pause

%draw y(x): the position of tatch jisi
plot(x(:,1),x(:,2),'r*'),grid
xlabel('x','FontSize',16),ylabel('y','FontSize',16)

⌨️ 快捷键说明

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