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 日

0 投票

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 件のコメント

ankanna
ankanna 2021 年 4 月 18 日
can you please explain deatail
David Fletcher
David Fletcher 2021 年 4 月 18 日
編集済み: David Fletcher 2021 年 4 月 18 日
ASCII value for char '0' is 48
ASCII value for char '1' is 49
A computer will translate char '0' - char '0' to 48 - 48 = 0
Similarly char '1' - char '0' will traslate to 49 - 48 = 1
So a vector of chars '110...' - '0' becomes 49 - 48, 49 - 48, 48 -48, ... = 1, 1, 0 ....
A computer has no conception of what a character is, much less subtracting what is essentially one squiggle from a different squiggle. It can only deal in numbers - to perform the subtraction, the computer uses the number values of the characters (ie. the ASCII values)
ankanna
ankanna 2021 年 4 月 18 日
thank you
ankanna
ankanna 2021 年 4 月 20 日
node = 3; ri=0.9;
L=(node*(node-1))/2;
configuration = dec2bin(0:(2^L-1))-'0';
alfak=configuration;
source node=1; destination node=3;
m = Limit on intermediate node;
2TR(alfak) == ri^m;
how to calculate two terminal reliability.
alfak Path 2TR(alfak)
1 r1r3 0.81
2 r1r3 0.81
3 r1r2r3 0.729
4 r1r3 0.81
5 None 0.00
6 r1r3 0.81
7 None 0.00
8 None 0.00
please help me to generate above and i want that 2terminal reliability at output.
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 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

リリース

R2016a

タグ

質問済み:

2021 年 4 月 18 日

コメント済み:

2021 年 4 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by