how to generate?

조회 수: 2 (최근 30일)
ankanna
ankanna 2021년 4월 18일
댓글: ankanna 2021년 4월 24일
format long g
nodes = 10;
lamda = 0.7;
bits = dec2bin(0:2^nodes-1)-'0';
nl = sum(bits,2);
nu = nodes-nl;
P = lamda.^nl .* (1-lamda).^nu;
P(1:20)
I see the answer works, but my question is why does the "- '0'" part changes the outcome from a series of chars to a doube format?
  댓글 수: 1
ankanna
ankanna 2021년 4월 18일
please help me why to give -'0'

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

채택된 답변

David Fletcher
David Fletcher 2021년 4월 18일
편집: David Fletcher 2021년 4월 18일
Consider the ASCII value for zero - the only way a computer can make sense of the subtraction is to subtract their ASCII values. So '0' - '0' results in a double of value zero. This also works for a '1' since the ASCII value for '1' is one greater than the ASCII value for '0'. So '1' - '0' results in a double value of 1
  댓글 수: 6
David Fletcher
David Fletcher 2021년 4월 20일
Although I have a vague idea that this relates to paths between network nodes, I am not familiar with the two terminal reliability metric, or how it is calculated. It is not in my direct field of knowledge, and to be honest I have minimal desire to go off and research it since it is likely of little personal use to me. You are more likely to find somebody who is versed in this field of research by posing this as a separate question on the forum.
ankanna
ankanna 2021년 4월 24일
n = 3;
Link=(n*(n-1))/2;
c=2^Link;
NN = toeplitz(Link+1:-1:2)
mask = logical(fliplr(diag(ones(1,Link-1),-1)));
NN(mask) = 1;
for c = 0:2^Link-1
l = bitget(c, NN)
end
the above code i generate all configuration matrix.
i need to generate all paths in this network.
please help me to generate all paths in the network

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interface-Based Instrument Communication에 대해 자세히 알아보기

태그

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by