作业帮 > 综合 > 作业

用matlab编程解数学题(急)

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/13 15:41:47
用matlab编程解数学题(急)
某缉私艇上的雷达发现正东方向15海里处有一艘走私船正以20海里/小时的速度向正北方向行驶,缉私艇立即以40海里/小时的速度前往拦截.用雷达艇进行跟踪,可保持缉私艇的速度方向始终指向走私船.试建立任意时刻的位置和缉私艇航线的数学模型,确定缉私船追上走私船的位置,求出追上时间.
文件1jisi.m
%Creat the function for jisi
%Let x(1)=x, x(2)=y
function dx=jisi(t,x,a,b,c)
s=sqrt((c-x(1))^2+(a*t-x(2))^2);
dx=[b*(c-x(1))/s;b*(a*t-x(2))/s];
文件2seajisi.m
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)

再问: 文件2到哪里结束呀?还有,就是好像没有定义“ts”呀?
再答: 就到图片的上方,ts在前几行,这是老师编的,应该不会有什么问题