数学建模第三次作业——追击问题

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验报告

机械工程及自动化75班

丁鑫

四人追击问题

问题:

在一个边长为1的正方形跑道的四个顶点上各站有一人,他们同时开始以等速顺时针追逐下一人,在追逐过程中,每个人时刻对准目标,试模拟追击路线。并讨论:

(1) 四个人能否追到一起?

(2)若能追到一起,则每个人跑过多少路程?

(3)追到一起所需要的时间(设速率为1)?

(4)如果四个人追逐的速度不一样,情况又如何呢

分析:

先建立坐标系,设计程序使从A,B,C,D 四个点同时出发,画出图形并判断。

程序设计流程:

四个人追击的速度相等,则有14321=====v v v v v 。针对这种情形,可有以下的程序。

hold on

axis([0 2 0 2]);

grid

A=[0,0];B=[0,1];C=[1,1];D=[1,0];

k=0;

s1=0;s2=0;s3=0;s4=0; %四个人分别走过的路程

t=0;

v=1;dt=0.002;

while k<10000

k=k+1;

plot(A(1),A(2),'r.','markersize',15);

plot(B(1),B(2),'b.','markersize',15);

plot(C(1),C(2),'m.','markersize',15);

plot(D(1),D(2),'k.','markersize',15);

e1=B-A;d1=norm(e1);

e2=C-B;d2=norm(e2);

e3=D-C;d3=norm(e3);

e4=A-D;d4=norm(e4);

fprintf('k=%.0f ',k)

fprintf('A(%.2f,%.2f) d1=%.2f ',A(1),A(2),d1) fprintf('B(%.2f,%.2f) d2=%.2f ',B(1),B(2),d2) fprintf('C(%.2f,%.2f) d3=%.2f ',C(1),C(2),d3) fprintf('D(%.2f,%.2f) d4=%.2f\n',D(1),D(2),d4) A=A+v*dt*e1/d1;

B=B+v*dt*e2/d2;

C=C+v*dt*e3/d3;

D=D+v*dt*e4/d4;

t=t+dt;

s1=s1+v*dt;

s2=s2+v*dt;

s3=s3+v*dt;

s4=s4+v*dt;

if norm(A-C)<=5.0e-3&norm(B-D)<=5.0e-3 break

end

end

t

s1

s2

s3

s4

部分运行结果:

k=481 A(0.52,0.52) d1=0.04 B(0.52,0.48) d2=0.04 C(0.48,0.48) d3=0.04 D(0.48,0.52) d4=0.04 k=482 A(0.52,0.52) d1=0.04 B(0.52,0.48) d2=0.04 C(0.48,0.48) d3=0.04 D(0.48,0.52) d4=0.04 k=483 A(0.52,0.52) d1=0.04 B(0.52,0.48) d2=0.04 C(0.48,0.48) d3=0.04 D(0.48,0.52) d4=0.04

k=484 A(0.52,0.51) d1=0.04 B(0.51,0.48) d2=0.04 C(0.48,0.49) d3=0.04 D(0.49,0.52) d4=0.04 k=485 A(0.52,0.51) d1=0.04 B(0.51,0.48) d2=0.04 C(0.48,0.49) d3=0.04 D(0.49,0.52) d4=0.04 k=486 A(0.52,0.51) d1=0.03 B(0.51,0.48) d2=0.03 C(0.48,0.49) d3=0.03 D(0.49,0.52) d4=0.03 k=487 A(0.52,0.51) d1=0.03 B(0.51,0.48) d2=0.03 C(0.48,0.49) d3=0.03 D(0.49,0.52) d4=0.03 k=488 A(0.52,0.51) d1=0.03 B(0.51,0.48) d2=0.03 C(0.48,0.49) d3=0.03 D(0.49,0.52) d4=0.03 k=489 A(0.52,0.51) d1=0.03 B(0.51,0.48) d2=0.03 C(0.48,0.49) d3=0.03 D(0.49,0.52) d4=0.03 k=490 A(0.52,0.50) d1=0.03 B(0.50,0.48) d2=0.03 C(0.48,0.50) d3=0.03 D(0.50,0.52) d4=0.03 k=491 A(0.52,0.50) d1=0.02 B(0.50,0.48) d2=0.02 C(0.48,0.50) d3=0.02 D(0.50,0.52) d4=0.02 k=492 A(0.52,0.50) d1=0.02 B(0.50,0.48) d2=0.02 C(0.48,0.50) d3=0.02 D(0.50,0.52) d4=0.02 k=493 A(0.51,0.50) d1=0.02 B(0.50,0.49) d2=0.02 C(0.49,0.50) d3=0.02 D(0.50,0.51) d4=0.02 k=494 A(0.51,0.50) d1=0.02 B(0.50,0.49) d2=0.02 C(0.49,0.50) d3=0.02 D(0.50,0.51) d4=0.02 k=495 A(0.51,0.50) d1=0.02 B(0.50,0.49) d2=0.02 C(0.49,0.50) d3=0.02 D(0.50,0.51) d4=0.02 k=496 A(0.51,0.50) d1=0.01 B(0.50,0.49) d2=0.01 C(0.49,0.50) d3=0.01 D(0.50,0.51) d4=0.01 k=497 A(0.51,0.49) d1=0.01 B(0.49,0.49) d2=0.01 C(0.49,0.51) d3=0.01 D(0.51,0.51) d4=0.01 k=498 A(0.51,0.49) d1=0.01 B(0.49,0.49) d2=0.01 C(0.49,0.51) d3=0.01 D(0.51,0.51) d4=0.01 k=499 A(0.50,0.49) d1=0.01 B(0.49,0.50) d2=0.01 C(0.50,0.51) d3=0.01 D(0.51,0.50) d4=0.01 k=500 A(0.50,0.50) d1=0.01 B(0.50,0.50) d2=0.01 C(0.50,0.50) d3=0.01 D(0.50,0.50) d4=0.01 k=501 A(0.50,0.50) d1=0.01 B(0.50,0.50) d2=0.01 C(0.50,0.50) d3=0.01 D(0.50,0.50) d4=0.01 k=502 A(0.50,0.50) d1=0.00 B(0.50,0.50) d2=0.00 C(0.50,0.50) d3=0.00 D(0.50,0.50) d4=0.00 t =

1.0040

s1 =

1.0040

s2 =

1.0040

s3 =

1.0040

s4 =

1.0040

从运行的结果来看,如果四个人的追击速度相同,均为1,可有以下的结果:

(1) 四人最后可以追到一起。

(2) 每个人跑过相等的路程,均为1.0040.

(3) 追到一起的时间为1.0040秒。

如果四个人追击的速度不一样,可取1,,3,2,4321=====v v v v v v v v v ,运行程序。 运行程序:

hold on

axis([0 2 0 2]);

grid

A=[0,0];B=[0,1];C=[1,1];D=[1,0];

k=0;

s1=0;s2=0;s3=0;s4=0; %四个人分别走过的路程

t=0;

v=1;dt=0.001;

相关文档
最新文档