- All nodes are active (ni = 1 for all i).
- m is the threshold probability for link formation.
how to generate code?
19 ビュー (過去 30 日間)
古いコメントを表示
procedure to simulate link status algarithm.
for i = 1,2,...,n
for j = i+1,...,n
test - select random number from uniform distribution between (0,1)
if (test<=;λ∩ni = 1∩nj = 1) then Li,j = 1
else; Li,j = 0
Lj,i = Li,j
L - load Li,j and Lj,i into the matrix L
this is the actual procedure to generate link status
program:-
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
the above program have some error that is on undefined variable or function is obtained. please help to correct this function.
0 件のコメント
回答 (1 件)
Anudeep Kumar
2025 年 6 月 5 日 13:21
Hey ankana,
If I understood your question correctly you're trying to simulate a link status matrix based on a probabilistic model, where links between nodes are established based on a threshold and node activity status.
Based on this assumption and my understanding the issue in the code is that ni and nj are not defined.
Assuming
A few changes in the code should provide the correct result:
nodes = 3;
m = 0.7;
l = zeros(nodes); % Initialize link matrix
n = ones(1, nodes); % Assume all nodes are active (ni = 1 for all i)
for i = 1:nodes
for j = i+1:nodes
test = unifrnd(0,1);
if n(i) == 1 && n(j) == 1
if test <= m
l(i,j) = 1;
else
l(i,j) = 0;
end
l(j,i) = l(i,j); % Symmetric link
end
end
end
L = l; % Final link status matrix
disp(L);
I hope this resolves the issue!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で MATLAB Report Generator についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!