clc
clear
close all
t0=0;tf=250;
step_qw=0.01;
p1=20;
q0=[(rand(1)-0.5)*p1;(rand(1)-0.5)*p1;0.2;0.2;
(rand(1)-0.5)*p1;(rand(1)-0.5)*p1;0.1;0.1;
(rand(1)-0.5)*p1;(rand(1)-0.5)*p1;0.1;0.1;
(rand(1)-0.5)*p1;(rand(1)-0.5)*p1;0.1;0.1;
(rand(1)-0.5)*p1;(rand(1)-0.5)*p1;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
plot(q(:,17),q(:,18),'c');
hold on
legend('leader ','follower 1','follower 2','follower 3','follower 4',4);
hold on
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(1,17),q(1,18),'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{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
plot(t,q(:,19),'m:',t,q(:,20),'m');
box on
legend('leader ','follower 1','follower 2','follower 3','follower 4',4);
figure(3)
hold on
xlabel('t/s','FontName','Times New Roman','FontSize',14);ylabel('xi-x0','interpreter','latex','fontsize',14);
hold on
plot(t,q(:,5)-q(:,1),'r:',t,q(:,6)-q(:,2),'r');
hold on
plot(t,q(:,9)-q(:,1),'b:',t,q(:,10)-q(:,2),'b');
hold on;
plot(t,q(:,13)-q(:,1),'k:',t,q(:,14)-q(:,2),'k');
hold on;
plot(t,q(:,17)-q(:,1),'m:',t,q(:,18)-q(:,2),'m');
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('vi-v0','interpreter','latex','fontsize',14);
hold on
plot(t,q(:,3)-q(:,7),'r:',t,q(:,4)-q(:,8),'r');
hold on
plot(t,q(:,3)-q(:,11),'b:',t,q(:,4)-q(:,12),'b');
hold on;
plot(t,q(:,3)-q(:,15),'k:',t,q(:,4)-q(:,16),'k');
hold on;
plot(t,q(:,3)-q(:,19),'m:',t,q(:,4)-q(:,20),'m');
hold on
box on
legend('leader ','follower 1','follower 2','follower 3','follower 4',4);
grid off
心梓
- 粉丝: 858
- 资源: 8042
最新资源
- (172740052)Python课程设计:SA19225391+王纵横+基于LSTM的古诗文生成系统1
- java项目,毕业设计-在线考试系统
- Arcgis统计要素图层字段信息工具箱
- 数据分析-32-被淘汰的6271家公司的特点分析
- 基于JavaWeb的小区物业管理系统源代码+数据库
- 基于python开发的大模型调用基础框架(源码)
- (176552216)30.基于51单片机的HX711传感器电子秤设计(实物).rar
- (177708036)ASP图书管理系统的设计与实现(源代码+LW).zip
- 数据分析-52-关于ADX游戏广告投放数据的探索
- DP83848以太网相关的代码程序
- (178931822)平差代码C#,测绘专业实用
- ISO16845 CAN一致性测试
- PrimeTime各版本User Guide
- vl53l0x激光测距stm32库函数程序源码
- data来源,用于做该篇文章实战
- 源码,用于做该篇文章实战
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页