Main Content


Demodulate and convert symbols to bits



out = nrSymbolDemodulate(in,mod) demodulates complex symbols in codeword in to soft bits using modulation scheme mod. The function implements the inverse of TS 38.211 Section 5.1 [1].

out = nrSymbolDemodulate(in,mod,nVar) specifies the noise variance scaling factor for the soft bits.

out = nrSymbolDemodulate(in,mod,'DecisionType',decision) specifies the demodulation decision mode by using a name-value pair argument.


collapse all

Generate a random sequence of binary values of length 40.

data = randi([0 1],40,1);

Generate modulated symbols using QPSK modulation.

modsymb = nrSymbolModulate(data,'QPSK'); 

Perform QPSK demodulation in soft decision mode for a noise variance of 0.1.

nVar = 0.1;
recsymb = awgn(modsymb,1/nVar,1,'linear');
out = nrSymbolDemodulate(recsymb,'QPSK',0.1);

Generate a random sequence of binary values of length 100.

data = randi([0 1],100,1,'int8');

Generate modulated symbols using 16-QAM modulation.

modsymb = nrSymbolModulate(data,'16QAM');

Add a noise to the modulated symbols corresponding to an SNR of 15 dB.

recsymb = awgn(modsymb,15);

Perform 16-QAM demodulation in hard decision mode.

demodbits = nrSymbolDemodulate(recsymb,'16QAM','DecisionType','Hard');

Check for bit errors.

numErr = biterr(data,demodbits)
numErr = 0

Input Arguments

collapse all

Codeword to demodulate, specified as a complex column vector.

Data Types: double | single
Complex Number Support: Yes

Modulation scheme, specified as 'pi/2-BPSK', 'BPSK', 'QPSK', '16QAM', '64QAM', '256QAM', or '1024QAM'. This modulation scheme determines the modulation type to be performed on the input codeword and the number of bits used per modulation symbol.

Modulation SchemeNumber of Bits Per Symbol




Data Types: char | string

Noise variance, specified as a nonnegative numeric scalar. The soft bits are scaled with the variance of additive white Gaussian noise (AWGN). The default value corresponds to an SNR of 100 dB, assuming unit signal power. This argument applies only for soft decision mode.


The default value assumes the modulator and demodulator are connected back-to-back where the noise variance is zero. To avoid +/-Inf values in the output, the function uses 1e-10 as default value for noise variance. To get appropriate results when the signal is transmitted through a noisy channel, adjust the noise variance accordingly.

Data Types: double

Decision mode, specified as 'soft' or 'hard'. The decision mode controls the demodulation type performed on the received symbols.

  • 'soft' — Soft decision mode results in a numeric output containing the bitwise approximation to the log-likelihood ratios of the demodulated bits. The output out inherits its data type from the input in.

  • 'hard'— Hard decision mode results in a binary output containing groups of bits corresponding to the closest constellation points to the input in. The output out is type-cast to int8.

Data Types: char | string

Output Arguments

collapse all

Demodulated output bits, returned as a numeric column vector or binary column vector. Demodulation is performed assuming the input constellation power normalization defined in TS 38.211 section 5.1 [1].

Modulation SchemeConstellation Power Normalization Factor





Each demodulated symbol is mapped to a group of bits corresponding to the number of bits per symbol in the modulation scheme mod. The first bit represents the most significant bit, and the last bit represents the least significant bit. The length of out is the length of the input in multiplied by the number of bits per symbol. The decision mode controls the content and the data type of the demodulated output bits.

Data Types: double | single | int8


[1] 3GPP TS 38.211. “NR; Physical channels and modulation.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

Extended Capabilities

Version History

Introduced in R2018b

expand all