solution for algorithm to link status?

조회 수: 2 (최근 30일)
ankanna
ankanna 2021년 3월 17일
댓글: ankanna 2021년 4월 8일
nodes = 3; m = 0.7
for i = 1:nodes
for j = i+1:nodes
test = unifrnd(0,1)
if ni = 1
nj = 1:nodes
if (test<=m/ni=1/nj=1)
li,j = 1
else
li,j = 0
end
lj,i = li,j
end
L = li,j;lj,i
end
please to generate this

채택된 답변

Walter Roberson
Walter Roberson 2021년 3월 17일
편집: Walter Roberson 2021년 3월 17일
nodes = 3; m = 0.7;
for i = 1:nodes
for j = i+1:nodes
test = unifrnd(0,1);
if ni == 1
nj = 1:nodes;
if (test<=m/ni==1./nj==1)
l(i,j) = 1;
else
l(i,j) = 0;
end
l(j,i) = l(i,j);
end
L = [l(i,j);l(j,i)];
end
end
However, we can prove that the if (test<=m/ni==1./nj==1) will be false except when nodes = 1 (in which case the code is just rather strange but could be true sometimes.)
  댓글 수: 31
ankanna
ankanna 2021년 4월 8일
if any possible to change this algarithm.
ankanna
ankanna 2021년 4월 8일
please to generate link status i.e., the output will be contain this matrix. how to generate this code
0 1 1
1 0 1
1 1 0

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by