大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
Matlab 仿真含时滞多智体一致性分析,附代码
系统结构如下图所示:
clear;
clc;
% 2014_多智能体网络的一致性问题研究_纪良浩
% 此为Paper中的示例代码
% 例2.1:
A = [0, 0, 0.1, 0, 0;
0.1, 0, 0, 0, 0;
0, 0.15, 0, 0, 0;
0, 0.25, 0, 0, 0;
0.2, 0, 0, 0, 0;];
D = [0, 0, 0, 0, 0;
0, 0, 0, 0, 0;
0, 0, 0, 0, 0;
0, 0, 0, 0, 0;
0, 0, 0, 0, 0;];
% 各节点间的通信时滞如下
T13 = 1.0;
T21 = 0.75;
T32 = 1.8;
T42 = 2.0;
T51 = 0.8;
% 输入时滞如下
T = 0.3;
% 各节点的随机初始状态如下
X = [2, 3.5, 2.5, 3, 5;]';
U = [0, 0, 0, 0, 0;]';
%% 更改时滞格式
% 各节点间的通信时滞如下
T13 = 10;
T21 = 7;
T32 = 18;
T42 = 20;
T51 = 8;
% 输入时滞如下
T = 3;
% 为了防止开始收敛前无状态,特扩充收敛前的状态
t = 0;
for i = 1:20
X(:, i+1) = X(:, i);
U(:, i+1) = U(:, i);
t(:, i+1) = t(:, i)+0.1;
i = i + 1;
end
%%
% 仿真相关参数如下
tBegin = 0;
tEnd = 60;
dt = 0.1;
times = (tEnd - tBegin)/dt;
time = 1;
% 计算过程如下
while (time <= times)
% 时间记录
t(1, time+20) = tBegin + dt * time + 19*0.1;
% 控制输入分别为
j = X(3, time+20-T13);
i = X(1, time+20-T);
a = A(1,3);
U(1, time+20) = sum( a * (j-i) );
U(2, time+20) = sum( A(2,1) * (X(1, time+20-T21)-X(2, time+20-T)) );
U(3, time+20) = sum( A(3,2) * (X(2, time+20-T32)-X(3, time+20-T)) );
U(4, time+20) = sum( A(4,2) * (X(2, time+20-T42)-X(4, time+20-T)) );
U(5, time+20) = sum( A(5,1) * (X(2, time+20-T51)-X(5, time+20-T)) );
% 状态更新为
X(1, time+21) = X(1, time+20) + U(1, time+20) * dt;
X(2, time+21) = X(2, time+20) + U(2, time+20) * dt;
X(3, time+21) = X(3, time+20) + U(3, time+20) * dt;
X(4, time+21) = X(4, time+20) + U(4, time+20) * dt;
X(5, time+21) = X(5, time+20) + U(5, time+20) * dt;
time = time + 1;
end
%% 绘制结果图
subplot(2,1,1);
plot(t,X(1,1:620), t,X(2,1:620), t,X(3,1:620), t,X(4,1:620), t,X(5,1:620), "linewidth",2);
legend("x_1", "x_2", "x_3", "x_4", "x_5");
subplot(2,1,2);
plot(t,U(1,:), t,U(2,:), t,U(3,:), t,U(4,:), t,U(5,:), "linewidth",2);
legend("u_1", "u_2", "u_3", "u_4", "u_5");
下图为默认输入时滞T=0.3s
的收敛情况:
下图为输入时滞T=2.0s
的收敛情况:
Ref:
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/187232.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...