bsc

Binary symmetric channel

Description

ndata = bsc(data,probability) passes the binary input signal data through a binary symmetric channel having the specified error probability. The channel introduces a bit error and processes each element of the input data independently. data must be an array of binary numbers or a Galois array in GF(2). probability must be a scalar from 0 to 1.

ndata = bsc(data,probability,streamhandle) accepts a random stream handle to generate uniform noise samples by using rand. Providing a random stream handle or using the reset (RandStream) function on the default random stream object enables you to generate repeatable noise samples. For more information, see RandStream.

ndata = bsc(data,probability,seed) accepts a seed value, for initializing the uniform random number generator, rand. If you want to generate repeatable noise samples, then either reset the random stream input before calling bsc or use the same seed input.

[ndata,err] = bsc(___) returns an array containing the channel errors, using any of the preceding syntaxes.

Examples

collapse all

Using the bsc function, introduce bit errors in the bits in a random matrix with probability 0.15.

z = randi([0 1],100,100); % Random matrix
nz = bsc(z,.15); % Binary symmetric channel
[numerrs, pcterrs] = biterr(z,nz) % Number and percentage of errors
numerrs = 1509
pcterrs = 0.1509

The output below is typical. For relatively small sets of data, the percentage of bit errors is not exactly 15% in most trials. If the size of the matrix z is large, the bit error percentage will be closer to the exact probability you specify.

Using the bsc function, introduce bit errors in the bits in a random matrix with probability 0.01. Use Viterbi decoder to decode message data.

Define trellis for Viterbi decoder. Generate and encode message data.

trel = poly2trellis([4 3],[4 5 17;7 4 2]);
msg = ones(10000,1);

Create objects for convolutional encoder, Viterbi decoder, and error rate calculator.

hEnc = comm.ConvolutionalEncoder(trel);
hVitDec = comm.ViterbiDecoder(trel, 'InputFormat','hard', 'TracebackDepth',...
2, 'TerminationMethod', 'Truncated');
hErrorCalc = comm.ErrorRate;

Encode the message data. Introduce bit errors. Display the total number of errors.

code = hEnc(msg);
[ncode,err] = bsc(code,.01);
numchanerrs = sum(sum(err))
numchanerrs = 158

Decode the data and check the number of errors after decoding.

dcode = hVitDec(ncode);
berVec = hErrorCalc(msg, dcode);
ber = berVec(1)
ber = 0.0049
numsyserrs = berVec(2)
numsyserrs = 49