追逐游戏MATLAB

函数zd501951828

%追逐游戏

% u=5时解微分方程

[t,Y] = ode45(@ode,[0 7.1],[0;0;0], [], 5);

Q = Y(:,1);

x 1 = 10+20 * cos(Q);

y 1 = 20+5 * sin(Q);

x2 = Y(:,2);

y2 = Y(:,3);

% u=20时解微分方程

[t,Y] = ode45(@ode,[0 1.9],[0;0;0], [], 20);

x3 = Y(:,2);

y3 = Y(:,3);

%绘制轨迹

德国戴姆勒集团旗下品牌梅赛德斯

绘图(x1,y1,' b:',x2,y2,' r:',x3,y3,' m:')

图例(' v = 1 ',' u = 5 ',' u = 20 ',4)

函数dY = ode(t,Y,u)

%追逐博弈的微分方程

q = Y(1);

x 1 = 10+20 * cos(Q);

y 1 = 20+5 * sin(Q);

x2 = Y(2);

y2 = Y(3);

Q2 = atan2(y1-y2,x 1-x2);

dx2 = u * cos(Q2);

dy2 = u * sin(Q2);

dq = 1/sqrt((-20*sin(q))^2+(5*cos(q))^2);

dY =[dQ;dx2dy2];