-2
作为帮助gnovice我得到了下面的代码,但现在我想分配能量(随机)到每个节点使用E=floor(rand(1)*10)
,也想比较最大能量和它们之间的距离是多少?如何将随机能量E分配给每个节点并比较两个节点的最大能量并找出它们之间的距离?
N=input('no. of nodes : '); %# Number of nodes
coords = num2cell(rand(N,2)) %# Cell array of random x and y coordinates
nodes=struct('x',coords(:,1),... %# Assign x coordinates
'y',coords(:,2)); %# Assign y coordinates
plot([nodes.x],[nodes.y],'r*'); %# Plot all the nodes in red
index = randi(N,[1 2]) %# Pick two nodes at random
hold on;
plot([nodes(index).x],[nodes(index).y],'b*'); %# Plot 2 random nodes in blue
index(1) %# which node is selected first.
index(2) %# which node is selected second.
这个问题是后续的this question。
如果您提到问题是后续问题,而不是仅仅提到后续问题,那么您可以帮助所有人回答您的问题。它是http://stackoverflow.com/questions/1749888/how-do-i-compare-elements-of-one-row-with-every-other-row-in-the-same-matrix-in-m? – 2009-12-13 16:56:53
对不起,我的朋友,从下次我会照顾它。 – gurwinder 2009-12-13 17:37:57