Info
此问题已关闭。 请重新打开它进行编辑或回答。
how to find eucledian distance b/w nodes only present in P(2,2)..............
1 次查看(过去 30 天)
显示 更早的评论
how can i select the nodes of cell(2,2) to find eucledian distance b/w the nodes present in this box ..................i have a problem if i write for i=1:1:N in cell(2,2) all N nodes present in the network are selected.......I only want to select the nodes of box P(2,2) not all N nodes of network................................help me how can i use "for" loop for selecting nodes of this box
7 个评论
回答(1 个)
KSSV
2016-9-9
编辑:KSSV
2016-9-9
npoints = length(P1{1}) ;
coor = P1{1} ;
dist = cell(npoints,1) ;
for i = 1:npoints % loop for each points, npoints is total number of points
data = repmat(coor(i,:),[length(coor),1])-coor ;
dist{i} = sqrt(data(:,1).^2+data(:,2).^2);
end
The above code calculates distance between nth node to other (n-1) nodes...The distances are stored in cell dist..dist{1} gives the distance between first node to other n-1 nodes.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!