Main Content

bsc

Binary symmetric channel

Description

ndata = bsc(data,probability) passes the binary input signal data through a binary symmetric channel with the specified error probability. The channel introduces a bit error and processes each element of the input data independently.

example

ndata = bsc(data,probability,seed) accepts a seed value for initializing the local random number generator.

ndata = bsc(data,probability,streamhandle) accepts a random stream handle to generate noise samples.

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

example

Examples

collapse all

Introduce bit errors in the bits of a random matrix with probability 0.15 by using the bsc function.

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

This output is typical for relatively small sets of data. The percentage of bit errors is not exactly 15% in most trials. To return a bit error percentage closer to the exact probability you specify, you can increase the size of the input matrix.

Introduce bit errors in the bits of a random vector with probability 0.01 by using the bsc function, and then decode the message data by using the vitdec function.

Define the trellis for convolutional encoding and Viterbi decoding. Generate message data.

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

Create an object for the error rate calculator.

errCalc = comm.ErrorRate;

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

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

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

dcode = vitdec(ncode,trel,2,"trunc","hard");
berVec = errCalc(msg,dcode);
ber = berVec(1)
ber = 
0.0049
numsyserrs = berVec(2)
numsyserrs = 
49

Input Arguments

collapse all

Input binary signal, specified as a scalar, vector, matrix, or 3-D array. This function provides Galois field support. For more information, see the gf function.

Data Types: double | single | logical | gf

Error probability, specified as a scalar in the interval [0, 1].

Random stream handle, specified as a RandStream object. This input specifies a random number stream to generate uniform random noise samples using rand. If you want to generate repeatable noise samples, reset the random stream input before calling bsc. For more information, see the RandStream function.

Seed value for initializing the uniform random number generator, rand. If you want to generate repeatable noise samples, use the same seed.

Output Arguments

collapse all

Output binary signal, returned as a scalar, vector, matrix, or 3-D array. This output has the same dimensions and data type as those of the input data.

Bit errors, returned as a scalar, vector, matrix, or 3-D array. This output has the same dimensions as data and ndata. At positions where the function introduces an error, err has the value 1. At other positions, the value is 0.

Extended Capabilities

Version History

Introduced before R2006a

See Also

Functions