How to count changes in binary transmission through channel
古いコメントを表示
Have a transmitter that transmits 100000 random binary bits through a noisy channel. Is there a function I can use to figure out how many of the bits received have changed? Thanks
回答 (1 件)
Sven
2011 年 11 月 15 日
Hmmm... does this answer your question, Will?
originalBits = rand(1,100000)>0.5;
returnedBits = transmitSignal(originalBits);
changedBits = xor(originalBits, returnedBits);
errorCount = nnz(changedBits);
errorRatio = errorCount / length(originalBits);
Obviously you need to have the function "transmitSignal", or some other way to get the original signal and the signal that was received into memory. Once you have these two variables, the "xor" command just returns whether a bit had changed or not. Let us know if your question is more specific than this.
As an example, maybe you just want to simulate errors by randomly changing some bits:
bitsToChange = rand(size(originalBits))>0.95;
returnedBits = originalBits;
returnedBits(bitsToChange) = ~returnedBits(bitsToChange);
changedBits = originalBits ~= returnedBits;
errorCount = nnz(changedBits);
errorRatio = errorCount / length(originalBits);
3 件のコメント
Walter Roberson
2011 年 11 月 15 日
The changedBits = xor(originalBits, returnedBits)
line could also be expressed as
changedBits = originalBits ~= returnedBits;
if you find that easier to understand -- or if your "bits" do not happen to have the values 0 and 1 (e.g, the +3 and -3 of your previous question.)
Sven
2011 年 11 月 15 日
@Walter: How dare you consistently follow up my answers with more correct or simple improvements?
Sven
2011 年 11 月 15 日
@Will: Walter's right (regardless of how much I resent it) - I'll change the second part of my example to use ~= and keep the first part as xor()
カテゴリ
ヘルプ センター および File Exchange で Communications Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!