clc
clear
close all
t0=0;tf=150;
step_qw=0.01;
p1=20;
q0= [(rand(1)-0.5)*p1;(rand(1)-0.5)*p1;
(rand(1)-0.5)*p1;(rand(1)-0.5)*p1;
(rand(1)-0.5)*p1;(rand(1)-0.5)*p1;
(rand(1)-0.5)*p1;(rand(1)-0.5)*p1;
(rand(1)-0.5)*p1;(rand(1)-0.5)*p1
];
%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(:,3),q(:,4),'r');
hold on
plot(q(:,5),q(:,6),'b');
hold on
plot(q(:,7),q(:,8),'k');
hold on
plot(q(:,9),q(:,10),'c');
hold on
legend('leader ','follower 1','follower 2','follower 3','follower 4',4);
plot(q(1,1),q(1,2),'ro');
hold on
plot(q(1,3),q(1,4),'bo');
hold on
plot(q(1,5),q(1,6),'bo');
hold on
plot(q(1,7),q(1,8),'bo');
hold on
plot(q(1,9),q(1,10),'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('Xi ','FontName','Times New Roman','FontSize',14);
plot(q(:,1),'g');
hold on
plot(q(:,3),'r');
hold on
plot(q(:,5),'b');
hold on
plot(q(:,7),'k');
hold on
plot(q(:,9),'c');
hold on
legend('leader ','follower 1','follower 2','follower 3','follower 4',4);
box on
figure(3);
hold on
xlabel('t/s','FontName','Times New Roman','FontSize',14);ylabel('Yi ','FontName','Times New Roman','FontSize',14);
plot(q(:,2),'g');
hold on
plot(q(:,4),'r');
hold on
plot(q(:,6),'b');
hold on
plot(q(:,8),'k');
hold on
plot(q(:,10),'c');
hold on
legend('leader ','follower 1','follower 2','follower 3','follower 4',4);
box on
figure(4)
hold on
xlabel('t/s','FontName','Times New Roman','FontSize',14);ylabel('xi-x0','interpreter','latex','fontsize',14);
hold on
plot(t,q(:,3)-q(:,1),'r:',t,q(:,4)-q(:,2),'r-');
hold on
plot(t,q(:,5)-q(:,1),'b:',t,q(:,6)-q(:,2),'b-');
hold on;
plot(t,q(:,7)-q(:,1),'k:',t,q(:,8)-q(:,2),'k-');
hold on;
plot(t,q(:,9)-q(:,1),'m:',t,q(:,10)-q(:,2),'m-');
hold on
legend('leader ','follower 1','follower 2','follower 3','follower 4',4);
box on
grid off
- 1
- 2
前往页