Main Content


Calculate bit error rate (BER) using semianalytic technique


ber = semianalytic(txsig,rxsig,modtype,M,Nsamp)
ber = semianalytic(txsig,rxsig,modtype,M,Nsamp,num,den)
ber = semianalytic(txsig,rxsig,modtype,M,Nsamp,EbNo)
ber = semianalytic(txsig,rxsig,modtype,M,Nsamp,num,den,EbNo)
[ber,avgampl,avgpower] = semianalytic(...)


ber = semianalytic(txsig,rxsig,modtype,M,Nsamp) returns the bit error rate (BER) of a system that transmits the complex baseband vector signal txsig and receives the noiseless complex baseband vector signal rxsig. Each of these signals has Nsamp samples per symbol. Nsamp is also the sampling rate of txsig and rxsig, in Hz. The function assumes that rxsig is the input to the receiver filter, and the function filters rxsig with an ideal integrator. modtype is the modulation type of the signal and M is the alphabet size. The table below lists the valid values for modtype and M.

Modulation SchemeValue of modtypeValid Values of M
Differential phase shift keying (DPSK) 'dpsk' 2, 4
Minimum shift keying (MSK) with differential encoding'msk/diff' 2
Minimum shift keying (MSK) with nondifferential encoding'msk/nondiff' 2
Phase shift keying (PSK) with differential encoding, where the phase offset of the constellation is 0 'psk/diff' 2, 4
Phase shift keying (PSK) with nondifferential encoding, where the phase offset of the constellation is 0 'psk/nondiff' 2, 4, 8, 16, 32, or 64
Offset quadrature phase shift keying (OQPSK) 'oqpsk' 4
Quadrature amplitude modulation (QAM) 'qam' 4, 8, 16, 32, 64, 128, 256, 512, 1024

'msk/diff' is equivalent to conventional MSK (setting the 'Precoding' property of the MSK object to 'off'), while 'msk/nondiff' is equivalent to precoded MSK (setting the 'Precoding' property of the MSK object to 'on').


The output ber is an upper bound on the BER in these cases:

  • DQPSK (modtype = 'dpsk', M = 4)

  • Cross QAM (modtype = 'qam', M not a perfect square). In this case, note that the upper bound used here is slightly tighter than the upper bound used for cross QAM in the berawgn function.

When the function computes the BER, it assumes that symbols are Gray-coded. The function calculates the BER for values of Eb/N0 in the range of [0:20] dB and returns a vector of length 21 whose elements correspond to the different Eb/N0 levels.


You must use a sufficiently long vector txsig, or else the calculated BER will be inaccurate. If the system's impulse response is L symbols long, the length of txsig should be at least ML. A common approach is to start with an augmented binary pseudonoise (PN) sequence of total length (log2M)ML. An augmented PN sequence is a PN sequence with an extra zero appended, which makes the distribution of ones and zeros equal.

ber = semianalytic(txsig,rxsig,modtype,M,Nsamp,num,den) is the same as the previous syntax, except that the function filters rxsig with a receiver filter instead of an ideal integrator. The transfer function of the receiver filter is given in descending powers of z by the vectors num and den.

ber = semianalytic(txsig,rxsig,modtype,M,Nsamp,EbNo) is the same as the first syntax, except that EbNo represents Eb/N0, the ratio of bit energy to noise power spectral density, in dB. If EbNo is a vector, then the output ber is a vector of the same size, whose elements correspond to the different Eb/N0 levels.

ber = semianalytic(txsig,rxsig,modtype,M,Nsamp,num,den,EbNo) combines the functionality of the previous two syntaxes.

[ber,avgampl,avgpower] = semianalytic(...) returns the mean complex signal amplitude and the mean power of rxsig after filtering it by the receiver filter and sampling it at the symbol rate.


collapse all

This example shows how to use the semianalytic technique for bit error rate analysis, using a 16-QAM modulated signal. It also compares the error rates obtained from the semianalytic technique with the theoretical error rates obtained from published formulas and computed using the berawgn function. The resulting plot shows that the error rates obtained using the two methods are nearly identical. The discrepancies between the theoretical and computed error rates are largely due to the phase offset inserted through a noiseless channel model.

Generate message signal of length >= ML.

M = 16; % Alphabet size of modulation
L = 1; % Length of impulse response of channel
msg = [0:M-1 0]; % M-ary message sequence of length > M^L

Modulate the message signal using baseband modulation.

modsig = qammod(msg',M); % Modulate data
Nsamp = 16;
modsig = rectpulse(modsig,Nsamp); % Use rectangular pulse shaping.

Apply a transmit filter.

txsig = modsig; % No filter in this example

Run txsig through a noiseless channel, applying a static phase offset of 1 degree.

rxsig = txsig*exp(1i*pi/180);

Use the semianalytic function.

Specify the receive filter as a pair of input arguments. In this case, num and den describe an ideal integrator.

num = ones(Nsamp,1)/Nsamp;
den = 1;
EbNo = 0:20; % Range of Eb/No values under study
ber = semianalytic(txsig,rxsig,'qam',M,Nsamp,num,den,EbNo);

For comparison, calculate theoretical BER.

bertheory = berawgn(EbNo,'qam',M);

Plot computed BER and theoretical BER.

figure; semilogy(EbNo,ber,'k*');
hold on; semilogy(EbNo,bertheory,'ro');
title('Semianalytic BER Compared with Theoretical BER');
legend('Semianalytic BER with Phase Offset',...
    'Theoretical BER Without Phase Offset','Location','SouthWest');
hold off;

Figure contains an axes. The axes with title Semianalytic BER Compared with Theoretical BER contains 2 objects of type line. These objects represent Semianalytic BER with Phase Offset, Theoretical BER Without Phase Offset.


The function makes several important assumptions about the communication system. See When to Use Semianalytic Technique to find out whether your communication system is suitable for the semianalytic technique and the semianalytic function.

More About

collapse all

When to Use Semianalytic Technique

The technique described in Performance Results via Simulation works well for a large variety of communication systems, but can be prohibitively time-consuming for small error rates (for example, 10-6 or smaller). This section describes how to use the semianalytic technique as an alternative way to compute error rates. For certain types of systems, the semianalytic technique can produce results faster than a nonanalytic method that uses simulated data only.

The communication system being simulated must satisfy these characteristics when using the semianalytic technique.

  • Any effects of multipath fading, quantization, and amplifier nonlinearities must precede the effects of noise in the actual channel being modeled.

  • The receiver is perfectly synchronized with the carrier, and timing jitter is negligible. Because phase noise and timing jitter are slow processes, they reduce the applicability of the semianalytic technique to a communications system.

  • The noiseless simulation has no errors in the received signal constellation. Distortions from sources other than noise should be mild enough to keep each signal point in its correct decision region. For instance, if the modeled system has a phase rotation that places the received signal points outside their proper decision regions, the semianalytic technique is not suitable to predict system performance.

If these characteristics are not satisfied, the calculated BER will be lower than expected. Furthermore, the semianalytic function assumes that the noise in the actual channel being modeled is Gaussian. For details on how to adapt the semianalytic technique for non-Gaussian noise, see the discussion of generalized exponential distributions in [1].

Procedure for Using Semianalytic Technique

These steps describe how you would typically implement the semianalytic technique by using the semianalytic function.

  1. Generate a message signal containing at least ML symbols, where M is the alphabet size of the modulation and L is the length of the impulse response of the channel in symbols. A common approach is to start with an augmented binary pseudonoise (PN) sequence of total length (log2M)ML. An augmented PN sequence is a PN sequence with an extra zero appended, which makes the distribution of ones and zeros equal.

  2. Modulate a carrier with the message signal using baseband modulation. Supported modulation types are listed on the reference page for semianalytic. Shape the resultant signal with rectangular pulse shaping, using the oversampling factor that you will later use to filter the modulated signal. Store the result of this step as txsig for later use.

  3. Filter the modulated signal with a transmit filter. This filter is often a square-root raised cosine filter, but you can also use a Butterworth, Bessel, Chebyshev type 1 or 2, elliptic, or more general FIR or IIR filter. If you use a square-root raised cosine filter, use it on the nonoversampled modulated signal and specify the oversampling factor in the filtering function. If you use another filter type, you can apply it to the rectangularly pulse shaped signal.

  4. Run the filtered signal through a noiseless channel. This channel can include multipath fading effects, phase shifts, amplifier nonlinearities, quantization, and additional filtering, but it must not include noise. Store the result of this step as rxsig for later use.

  5. Invoke the semianalytic function using the txsig and rxsig data from earlier steps. Specify a receive filter as a pair of input arguments, unless you want to use the default filter in the semianalytic function. The function filters rxsig and then determines the error probability of each received signal point by analytically applying the Gaussian noise distribution to each point. The function averages the error probabilities over the entire received signal to determine the overall error probability. If the error probability calculated in this way is a symbol error probability, the function converts it to a bit error rate, typically by assuming Gray coding. The function returns the bit error rate (or, in the case of DQPSK modulation, an upper bound on the bit error rate).


[1] Jeruchim, Michel C., Philip Balaban, and K. Sam Shanmugan. Simulation of Communication Systems. Second edition. Boston, MA: Springer US, 2000.

[2] Pasupathy, S., “Minimum Shift Keying: A Spectrally Efficient Modulation,” IEEE Communications Magazine, July, 1979, pp. 14–22.

Introduced before R2006a