我想用连接矩阵计算节点聚类系数分布但是当我操作这段代码时,它什么也没返回。问题是什么?我不能像那样使用函数图吗?
cm = [0,1,1,1,0;1,0,0,1,0;0,1,0,0,0;1,0,0,0,0;0,0,0,0,0];
bg = biograph(cm);
for i = 1:5
intNodes = getrelatives(bg.nodes(i));
num = numel(intNodes);
plot(i,num);
end
我想用连接矩阵计算节点聚类系数分布但是当我操作这段代码时,它什么也没返回。问题是什么?我不能像那样使用函数图吗?
cm = [0,1,1,1,0;1,0,0,1,0;0,1,0,0,0;1,0,0,0,0;0,0,0,0,0];
bg = biograph(cm);
for i = 1:5
intNodes = getrelatives(bg.nodes(i));
num = numel(intNodes);
plot(i,num);
end
每次调用 plot 都会删除以前绘制的数据,除非你写
hold on
在循环之前(或者除非您编辑轴属性)。
cm = [0,1,1,1,0;1,0,0,1,0;0,1,0,0,0;1,0,0,0,0;0,0,0,0,0];
bg = biograph(cm);
figure %# create new figure
hold on %# create axes, make sure that plots get added instead of replaced
for i = 1:5
intNodes = getrelatives(bg.nodes(i));
num = numel(intNodes);
plot(i,num);
end
如果您首先收集所有数据点,然后仅在最后绘制它们,您的代码可能会运行得更好。这是如何做到的:
cm = [0,1,1,1,0;1,0,0,1,0;0,1,0,0,0;1,0,0,0,0;0,0,0,0,0];
bg = biograph(cm);
plotData = NaN(5,1)
for i = 1:5
intNodes = getrelatives(bg.nodes(i));
num = numel(intNodes);
plotData(i)=num
end
plot(1:5,plotData)