how to generate?
1 次查看(过去 30 天)
显示 更早的评论
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?
采纳的回答
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
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interface-Based Instrument Communication 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!