how i can solve this proble of degree!!!!​!!!!!!!!!?​??????????​??????,

1 回表示 (過去 30 日間)
ali hadjer
ali hadjer 2015 年 11 月 9 日
コメント済み: Walter Roberson 2016 年 4 月 7 日
i want to count a nombre of neighbor of node (degree(i,j))but i obtained a float number(like 45.4288)and somtimes a nombre < of total of numbre (50 node and 103.2446 neighbor !!!!!! its impossible) pllllllz help me my code :
degree=[];
if isfield(handles,'net')
for i = 1:numel(handles.net(1,:))
for j = 1:numel(handles.net(1,:))
degree(i,j)=0;
X1 = handles.net(2,i);
Y1 = handles.net(3,i);
X2 = handles.net(2,j);
Y2 = handles.net(3,j);
xSide = abs(X2-X1);
ySide = abs(Y2-Y1);
d = sqrt(xSide^2+ySide^2);% distance euclidienne
DD(i,j)=d %matrice de distance entre noeuds
%RESORTIR LES NOEUD REDONDANTS
if (DD(i,j)< 2*(handles.r))&&(i~=j)
degree(i,j)=degree(i,j)+1;% CALCULE LEs nombre de neighbord( DEGRE) DES NOEUDS REDONDANTS
disp(degree(i,j));
end;
end
end

回答 (1 件)

Geoff Hayes
Geoff Hayes 2015 年 11 月 9 日
ali - your above code would never set a non-integer number as any element in the degree array since all you ever do is just increment any element by one. So I think that you have not provided the code that generates the error that you are observing.
One problem that I do see with your code is the use of degree. Why is it an nxn matrix where you consider each pair? Because that would mean that you would only ever have ones or zeros in this matrix. If you want to find the degree (number of neighbours) for each node, then if you have n nodes, your degree array would be nx1. And so your code would be as follows
if isfield(handles,'net')
n = numel(handles.net(1,:);
degrees = zeros(n,1);
for u=1:n
X1 = handles.net(2,u);
Y1 = handles.net(3,u);
for v=1:n
X2 = handles.net(2,v);
Y2 = handles.net(3,v);
xSide = abs(X2-X1);
ySide = abs(Y2-Y1);
d = sqrt(xSide^2+ySide^2);% distance euclidienne
DD(u,v)=d; %matrice de distance entre noeuds
%RESORTIR LES NOEUD REDONDANTS
if (DD(u,v)< 2*(handles.r))&&(u~=v)
degree(u)=degree(u)+1;
end;
end
end
end
  3 件のコメント
Geoff Hayes
Geoff Hayes 2015 年 11 月 10 日
ali - I don't understand your question. Please clarify.
Walter Roberson
Walter Roberson 2016 年 4 月 7 日
Please start a new Question about that

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by