Skip to main content
Home Wireless Communication Modulation MATLAB Beamforming Project Ideas MIMO Computer Networks Lab 🚀

MATLAB code for BER vs SNR for M-QAM, M-PSK, QPSk, BPSK, ...


 

MATLAB Script for BER vs. SNR for M-QAM, M-PSK, QPSk, BPSK


Output





If M>8, the distance between constellation points is short, and a higher Eb/No (SNR per Bit) ratio is required to reach the desired BER. Although the mapping from the data bits is arbitrary, some data bits are typically used. Every constellation point in the M-PSK constellation has two neighbors, each with an equal chance of making an error. As there are four bits per symbol, BER assumes a one-bit error for every mistake in a character. The demodulator in PSK must be able to calculate the received sinusoid's phase about some reference phase. While using the same bandwidths as ASK, PSK is less prone to errors than ASK. Also, using bandwidth with a significant data rate is more effective.

In the above figure, it is clear that PSK is more robust than QAM in the context of noise resilience. QAM modulations, including 16-QAM, are sensitive to both amplitude and phase errors. As you increase the number of constellation points (e.g., from 16-QAM to 8-PSK), the signal becomes more susceptible to amplitude and phase noise. In contrast, PSK modulations primarily rely on phase information and may be less sensitive to amplitude variations. This can make 8-PSK more robust in this scenario. 

QAM schemes require a higher SNR to achieve the same error rates as PSK schemes with the same number of constellation points. This means that 16-QAM may require a higher SNR than 8-PSK to achieve a satisfactory bit error rate (BER) or symbol error rate (SER). In practical communication systems, achieving the necessary SNR can be challenging, especially in noisy or fading channels.

MATLAB Code for BER vs SNR for m-ary QAM

clc;
clear all;
close all;


% Set parameters
snr_dB = -20:2:20; % SNR values in dB
qam_orders = [4, 16, 64, 256]; % QAM modulation orders

% Loop through each QAM order
for qam_order = qam_orders
% Calculate theoretical BER using berawgn
ber = berawgn(snr_dB, 'qam', qam_order);

% Plot the results
semilogy(snr_dB, ber, 'o-', 'DisplayName', sprintf('%d-QAM', qam_order));
hold on;
end

% Add labels and legend
title('BER vs SNR for Variable QAM');
xlabel('SNR (dB)');
ylabel('Bit Error Rate (BER)');
grid on;
legend('Location', 'best');

Output

 

Fig: BER vs SNR graph for Various QAM
 

Copy the aforementioned MATLAB Code from Here

 

 

MATLAB Code for BER vs SNR for m-ary PSK

clc;
clear all;
close all;

% Parameters
num_symbols = 1e5; % Number of symbols
snr_db = 0:2:20; % Range of SNR values in dB

% PSK orders to be tested
psk_orders = [2, 4, 8, 16, 32];

% Initialize BER arrays
ber_results = zeros(length(psk_orders), length(snr_db));

% BER calculation for each PSK order and SNR value
for i = 1:length(psk_orders)
psk_order = psk_orders(i);

for j = 1:length(snr_db)
% Generate random symbols
data_symbols = randi([0, psk_order-1], 1, num_symbols);

% Modulate symbols to generate signal
modulated_signal = pskmod(data_symbols, psk_order);

% Add AWGN to the signal
snr_linear = 10^(snr_db(j)/10);
received_signal = awgn(modulated_signal, snr_db(j), 'measured');

% Demodulate received signal
demodulated_symbols = pskdemod(received_signal, psk_order);

% Calculate BER
ber_results(i, j) = sum(data_symbols ~= demodulated_symbols) / num_symbols;
end
end

% Plot BER vs. SNR
figure;
semilogy(snr_db, ber_results(1, :), 'o-', 'DisplayName', 'BPSK');
hold on;

for i = 2:length(psk_orders)
semilogy(snr_db, ber_results(i, :), 'o-', 'DisplayName', sprintf('%d-PSK', psk_orders(i)));
end

title('BER vs. SNR for Various PSK Schemes');
xlabel('SNR (dB)');
ylabel('Bit Error Rate (BER)');
legend('Location', 'best');
grid on;
hold off;

Output

 
Fig: BER vs SNR graph for various PSK
 

Copy the above code from here



Read more about

People are good at skipping over material they already know!

View Related Topics to







Admin & Author: Salim

profile

  Website: www.salimwireless.com
  Interests: Signal Processing, Telecommunication, 5G Technology, Present & Future Wireless Technologies, Digital Signal Processing, Computer Networks, Millimeter Wave Band Channel, Web Development
  Seeking an opportunity in the Teaching or Electronics & Telecommunication domains.
  Possess M.Tech in Electronic Communication Systems.


Contact Us

Name

Email *

Message *

Popular Posts

MIMO, massive MIMO, and Beamforming

  The term 'MIMO' was originally applied to systems with multiple antennas on both the transmitter (Tx) and receiver (Rx) sides. MIMO is a key component of Wi-Fi 4 and 5, 3G, and 4G cellular networks. This method was introduced to increase the capacity of a channel by sending multiple simultaneous data streams through a single channel. All simultaneous data streams in a MIMO system are encoded orthogonally multiplexed, which reduces interference. Massive MIMO is used extensively in 5G to achieve extremely high capacity and to communicate via  beamforming  or directional transmission. 1. Some essential characteristics of a MIMO system 1.1. Spatial Division Multiplexing Access (SDMA) SDMA is a key feature of MIMO, allowing a base station (BS) to communicate with several devices simultaneously (or even using the same frequency) if they are in different locations. There may be no knowledge of channel information at the transmitter. 1.2. Spatial Multiplexing Another essential ...

BER vs SNR for M-ary QAM, M-ary PSK, QPSK, BPSK, ...

Modulation Constellation Diagrams BER vs. SNR BER vs SNR for M-QAM, M-PSK, QPSk, BPSK, ... 1. What is Bit Error Rate (BER)? The abbreviation BER stands for bit error rate, which indicates how many corrupted bits are received (after the demodulation process) compared to the total number of bits sent in a communication process. It is defined as,  In mathematics, BER = (number of bits received in error / total number of transmitted bits)  On the other hand, SNR refers to the signal-to-noise power ratio. For ease of calculation, we commonly convert it to dB or decibels.   2. What is Signal the signal-to-noise ratio (SNR)? SNR = signal power/noise power (SNR is a ratio of signal power to noise power) SNR (in dB) = 10*log(signal power / noise power) [base 10] For instance, the SNR for a given communication system is 3dB. So, SNR (in ratio) = 10^{SNR (in dB) / 10} = 2 Therefore, in this instance,...

Calculation of SNR from FFT bins

  Here, you can find the SNR of a received signal from periodogram / FFT bins using the Kaiser operator. The beta (β) parameter characterizes the Kaiser window, which controls the trade-off between the main lobe width and the side lobe level in the frequency domain. For that you should know the sampling rate of the signal.  The Kaiser window is a type of window function commonly used in signal processing, particularly for designing finite impulse response (FIR) filters and performing spectral analysis. It is a general-purpose window that allows for control over the trade-off between the main lobe width (frequency resolution) and side lobe levels (suppression of spectral leakage). The Kaiser window is defined using a modified Bessel function of the first kind.    Steps Set up the sampling rate and time vector Compute the FFT and periodogram Plot the periodogram using FFT Specify parameters for Kaiser window and periodogram Calculate the frequency resolution and signal...

Difference between AWGN and Rayleigh Fading

Wireless Signal Processing Gaussian and Rayleigh Distribution Difference between AWGN and Rayleigh Fading 1. Introduction Rayleigh fading coefficients and AWGN, or additive white gaussian noise [↗] , are two distinct factors that affect a wireless communication channel. In mathematics, we can express it in that way.  Fig: Rayleigh Fading due to multi-paths Let's explore wireless communication under two common noise scenarios: AWGN (Additive White Gaussian Noise) and Rayleigh fading. y = h*x + n ... (i) Symbol '*' represents convolution. The transmitted signal  x  is multiplied by the channel coefficient or channel impulse response (h)  in the equation above, and the symbol  "n"  stands for the white Gaussian noise that is added to the signal through any type of channel (here, it is a wireless channel or wireless medium). Due to multi-paths the channel impulse response (h) changes. And multi-paths cause Rayleigh fa...

MATLAB Code for QAM (Quadrature Amplitude Modulation)

  One of the best-performing modulation techniques is QAM [↗] . Here, we modulate the symbols by varying the carrier signal's amplitude and phase in response to the variation in the message signal (or voltage variation). So, we may say that QAM is a combination of phase and amplitude modulation. Additionally, it performs better than ASK or PSK [↗] . In fact, any constellation for any type of modulation, signal set (or, symbols) is structured in a way that prevents them from interacting further by being distinct by phase, amplitude, or frequency. MATLAB Script % This code is written by SalimWirelss.Com % This is an example of 4-QAM. Here constellation size is 4 % or total number of symbols/signals is 4 % We need 2 bits once to represent four constellation points % QAM modulation is the combination of Amplitude modulation plus % Phase Modulation. We map the decimal value of the input symbols, i.e., % 00, 01, 10, 11 to 1 + 1i, -1 + 1i, 1 - 1i, and -1 - 1i, respectively. clc;clear all;...

What is the process of beamforming in MIMO / Massive MIMO systems?

MIMO / Massive MIMO Beamforming Techniques What is the process of beamforming in the MIMO system? Beamforming is a technology that has been around for years. Beamforming is a technique for focusing a signal in a specific direction to be received at maximum gain at the receiver side. Because signal transmission from the transmitter to the receiver is directional, the receiver receives a greater signal in this process. When we send a signal from the transmitter to the receiver, the transmitter antenna spreads the signal out in an omnidirectional pattern. It'll be much easier if you've observed an antenna's radiation pattern. Using a directional beam, you can think of beamforming as directional communication between a transmitter and receiver. More than one antenna element is required to form a beam. They will, of course, be closely spaced for proper beam forming. The resultant phase of the signals will be fixed when we send si...

Minimum Shift Keying (MSK)

  Minimum shift keying (MSK) is a type of continuous frequency shift keying (CFSK). Like continuous frequency shift keying, we can also define bit "1" and "0" by two distinct frequency carriers, but the frequency shift will be half of the baud rate, i.e., f2 - f1 will be Rb/2. where f2 is the carrier frequency for binary bit "1" f1 is the carrier frequency for binary bit "0" Rb = Baud Rate   Here, the frequency shift between two carrier frequencies is minimum (Baud Rate) / 2. So, it is called minimum shift keying. Steps for minimum shift keying 1. Firstly, generate a bitstream of binary bits "1" and "0" 2. Then Convert it to NRZ Signal 3. Then perform MSK modulation on the NRZ Signal 4. If the carrier frequency is fc, then bit "1" will be represented by slightly higher than the carrier frequency, fc + (baud rate)/4, and bit "0" by slightly lower than the carrier frequency, fc - (baud rate)/4. Gaussian minim...

Gaussian minimum shift keying (GMSK)

Dive into the fascinating world of GMSK modulation, where continuous phase modulation and spectral efficiency come together for robust communication systems! Core Process of GMSK Modulation Phase Accumulation (Integration of Filtered Signal) After applying Gaussian filtering to the Non-Return-to-Zero (NRZ) signal, we integrate the smoothed NRZ signal over time to produce a continuous phase signal: θ(t) = ∫ 0 t m filtered (Ï„) dÏ„ This integration is crucial for avoiding abrupt phase transitions, ensuring smooth and continuous phase changes. Phase Modulation The next step involves using the phase signal to modulate a high-frequency carrier wave: s(t) = cos(2Ï€f c t + θ(t)) Here, f c is the carrier frequency, and s(t) represents the continuous-phase modulated carrier wave. Quadrature Modulation (Optional) ...