Info

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

how can i do to plot node i and eliminate node j?

1 回表示 (過去 30 日間)
ali hadjer
ali hadjer 2015 年 11 月 15 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
hello
i have this programm in matlab:
net = [1:n;rand([1,n])*x;rand([1,n])*y];
net1 = net;
hold on;
plot(net(2,:),net(3,:),'bo','MarkerSize',5,'MarkerFaceColor','b');
an i want to eliminate in plot a nodes j * whos distance is inferieur than *r (range) of the first node i but she doesn't work :
figure;
if isfield(handles,'net')
n=numel(handles.net(1,:));
for i = 1:n
% for j = i+1:n
for j = 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(i,j) = sqrt(xSide^2+ySide^2);% distance euclidienne ENTRE NOEUD
end
end
for i = 1:n
for j = 1:n
if (d(i,j)<=(handles.r) )
handles.net(2,j)=0;
handles.net(3,j)=0;
plot([X1,Y1],[X2,Y2],'bo','MarkerSize',5,'MarkerFaceColor','b');
end
end
end
end
  1 件のコメント
Jan
Jan 2015 年 11 月 15 日
I do not understand the question and the connection to the posted code.

回答 (2 件)

Walter Roberson
Walter Roberson 2015 年 11 月 16 日
After the plot() call, add the line
hold on

ISRAA ADIL HAYDER AL-RUBAYE
ISRAA ADIL HAYDER AL-RUBAYE 2020 年 9 月 5 日
seperate plots one for net(2,:) then Hold on then write a nother plot net (net(3,:) then Hold off
to seperate one plot from other
i hope that solves your problem

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by