0

我真的可以在这里使用一些建议:

所以,我应该做的是在图上模拟一个包含场景(这意味着网络的每个节点最终都将加入由图领导者的状态定义的凸包;在这种情况下,领导者是静止的并且图的拓扑是固定的)。该程序基于以下内容:

Xi(k+1) = Xi(k) if node i is a leader on the graph  
Xi(k+1) = Xi(k) + ∑Aij*(Xj(k)-Xi(k)) if node i is a follower on the graph
[if interested, more info in "containment control with 
 multiple stationary or dynamic leaders under a directed interaction graph]  

我对代码的想法是从随机输入开始并详细说明,直到达到遏制为止。到目前为止我做了什么:

clear all
clc
%%adjacency matrix; 4 leaders; 10 followers
%%leaders are not connected to other nodes 
a=round(rand(14,14));
a=round((a+a')/2);
a([1:4],[1:end])=0;
a([1:end],[1:4])=0;
a=max(eye(14),a);
%%random inputs for leaders and followers; convex hull;
sl=randi(10,[2,4]);
cv=convhull(sl');
sf=randi(10,[2,10]);
s=[sl sf];
%%i need to compare the state of each follower with the convex hull
ssf=sf(:);    
for i = 1 : length(ssf)
b =   ssf(i)==cv(1:end);
c(:,i) = b;
end
j=sum(c);
s0=zeros(size(s));
%%go on with the procedure until j isnt a ones(1,20)
while (sum(j) <= 20)
s0=s;
for i = 1 : 14 
for j = 1 : 14
s0(:,i) = s0(:,i) + a(i,j)*(s(:,j) - s(:,i));
end
end 
s0=s;
sl=s(1:2,1:4);
sf=s(1:2,5:end);
ssf=sf(:);
for i = 1 : length(ssf)
b =   ssf(i)==cv(1:end);
c(:,i) = b;
end
j=sum(c);
end  

代码有问题,但我无法修复它

4

0 回答 0