Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to find eucledian distance b/w nodes only present in P(2,2)..............

1 回表示 (過去 30 日間)
kiranpreet kaur
kiranpreet kaur 2016 年 9 月 9 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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 件のコメント
kiranpreet kaur
kiranpreet kaur 2016 年 9 月 9 日
編集済み: kiranpreet kaur 2016 年 9 月 9 日
yes sir i mean only P1(1,1).......
kiranpreet kaur
kiranpreet kaur 2016 年 9 月 9 日
編集済み: kiranpreet kaur 2016 年 9 月 9 日
nodes present in P1(1,1)......I have to form clusters of that nodes I know how to form the clusters but I can't how to use for loop for these nodes present in P1(1,1)..........In code line dist = cell(N,1) ; what could i write instead of N that only distance would be calculated of the points present inside P1(1,1)........sir help me in above code so as further i could form the clusters of the nodes present in that box

回答 (1 件)

KSSV
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.
  2 件のコメント
kiranpreet kaur
kiranpreet kaur 2016 年 9 月 9 日
thanks a lot sir............it really helps me a lot
kiranpreet kaur
kiranpreet kaur 2016 年 9 月 11 日
sir actually, now i add LEACH code in above program to make clusters in P1(1,1) but i got an error...........sir plz help me in my code so that clusters are formed in P1(1,1)........plz help me in my coding to form clusters in box P1(1,1)

この質問は閉じられています。

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by