??? Attempted to access degree(2); index out of bounds because numel(degree)=1.

1 回表示 (過去 30 日間)
ali hadjer
ali hadjer 2015 年 11 月 13 日
回答済み: Walter Roberson 2015 年 11 月 13 日
hello
i have a matrice triangular of distance(n,n) between nodes and i want to calculate the degree (the degree is a vector(n)) :
  • gca;
if isfield(handles,'net')
n=numel(handles.net(1,:));
degree=0;
for i = 1:n
for j = i+1:n
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);%
if (d<=2*(handles.r) )
degree(i)= degree(i)+1
end
end
end
end
and have this msg error :
??? Attempted to access degree(2); index out of bounds because numel(degree)=1.
Error in ==> technique_optimisation>pushbutton5_Callback at 429
degree(i)= degree(i)+1

採用された回答

Walter Roberson
Walter Roberson 2015 年 11 月 13 日
Change
degree=0;
to
degree = zeros(n,1);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Microsoft .NET についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by