clc
clear
close all
t0=0;tf=15;
step_qw=0.01;
p1=20;Y=0.1;M=0.15;N=0.275;
q0=[0.0; 0.0; 0.1; 0.1;
0.0; 0.4; 0.1; 0.1;
0.4; 0.1; 0.1; 0.1;
0.2; 0.6; 0.1; 0.1];
%save('q0.mat','q0');
load('q0.mat','q0');
[t,q]=ode45('Whole_Twodimension_total_state',t0:step_qw:tf,q0);
figure(1);
hold on
xlabel('x position','FontName','Times New Roman','FontSize',14);ylabel('y position','FontName','Times New Roman','FontSize',14);
plot(q(:,1),q(:,2),'g');
hold on
plot(q(:,5),q(:,6),'r');
hold on
plot(q(:,9),q(:,10),'b');
hold on
plot(q(:,13),q(:,14),'k');
hold on
legend('agent 1','agent 2','agent 3','agent 4',4);
plot(q(1,1),q(1,2),'ro');
hold on
plot(q(1,5),q(1,6),'bo');
hold on
plot(q(1,9),q(1,10),'bo');
hold on
plot(q(1,13),q(1,14),'bo');
hold on
plot(q(end,1),q(end,2),'rp');
hold on
box on
figure(2)
hold on
xlabel('t/s','FontName','Times New Roman','FontSize',14);ylabel('$\bar{x}_i$','interpreter','latex','fontsize',14);
hold on
plot(t,q(:,1),'r:',t,q(:,2),'r');
hold on
plot(t,q(:,5),'b:',t,q(:,6),'b');
hold on;
plot(t,q(:,9),'k:',t,q(:,10),'k');
hold on;
plot(t,q(:,13),'m:',t,q(:,14),'m');
hold on
legend('agent 1','agent 2','agent 3','agent 4',4);
box on
figure(3)
hold on
xlabel('t/s','FontName','Times New Roman','FontSize',14);ylabel('$\bar{v}_i$','interpreter','latex','fontsize',14);
hold on
plot(t,q(:,3),'r:',t,q(:,4),'r');
hold on
plot(t,q(:,7),'b:',t,q(:,8),'b');
hold on;
plot(t,q(:,11),'k:',t,q(:,12),'k');
hold on;
plot(t,q(:,15),'m:',t,q(:,16),'m');
hold on
legend('agent 1','agent 2','agent 3','agent 4',4);
box on
figure(4)
hold on
xlabel('t/s','FontName','Times New Roman','FontSize',14);ylabel('vi-$\bar{v}_i$','interpreter','latex','fontsize',14);
hold on
plot(t,q(:,3)-Y,'r:',t,q(:,4)-Y,'r');
hold on
plot(t,q(:,7)-Y,'b:',t,q(:,8)-Y,'b');
hold on;
plot(t,q(:,11)-Y,'k:',t,q(:,12)-Y,'k');
hold on;
plot(t,q(:,15)-Y,'m:',t,q(:,16)-Y,'m');
hold on
legend('agent 1','agent 2','agent 3','agent 4',4);
box on
%figure(4)
%hold on
%xlabel('t/s','FontName','Times New Roman','FontSize',14);ylabel('','interpreter','latex','fontsize',14);
%hold on
%plot(t,q(:,1)-M,'r:',t,q(:,2)-N,'r');
%hold on
%plot(t,q(:,5)-M,'b:',t,q(:,6)-N,'b');
%hold on;
%plot(t,q(:,9)-M,'k:',t,q(:,10)-N,'k');
%hold on;
%plot(t,q(:,13)-M,'m:',t,q(:,14)-N,'m');
%hold on
%box on
grid off
评论1