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

Rayleigh vs Rician Fading

  In Rayleigh fading, the channel coefficients tend to have a Rayleigh distribution, which is characterized by a random phase and magnitude with an exponential distribution. This means the magnitude of the channel coefficient follows an exponential distribution with a mean of 1. In Rician fading, there is a dominant line-of-sight component in addition to the scattered components. The channel coefficients in Rician fading can indeed tend towards 1, especially when the line-of-sight component is strong. When the line-of-sight component dominates, the Rician fading channel behaves more deterministically, and the channel coefficients may tend towards the value of the line-of-sight component, which could be close to 1.   MATLAB Script clc; clear all; close all; % Define parameters numSamples = 1000; % Number of samples K_factor = 5; % K-factor for Rician fading SNR_dB = 20; % Signal-to-noise ratio (in dB) % Generate complex Gaussian random variable for Rayleigh fading channel h_rayleigh = (

Comparisons among ASK, PSK, and FSK | And the definitions of each

Modulation ASK, FSK & PSK Constellation MATLAB Simulink MATLAB Code Comparisons among ASK, PSK, and FSK    Comparisons among ASK, PSK, and FSK Comparison among ASK,  FSK, and PSK Performance Comparison: 1. Noise Sensitivity:    - ASK is the most sensitive to noise due to its reliance on amplitude variations.    - PSK is less sensitive to noise compared to ASK.    - FSK is relatively more robust against noise, making it suitable for noisy environments. 2. Bandwidth Efficiency:    - PSK is the most bandwidth-efficient, requiring less bandwidth than FSK for the same data rate.    - FSK requires wider bandwidth compared to PSK.    - ASK's bandwidth efficiency lies between FSK and PSK. Bandwidth Calculator for ASK, FSK, and PSK The baud rate represents the number of symbols transmitted per second Select Modulation Type: ASK FSK PSK Baud Rate (Hz):

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, the signal power i

Constellation Diagrams of ASK, PSK, and FSK

Modulation ASK, FSK & PSK Constellation BASK (Binary ASK) Modulation: Transmits one of two signals: 0 or -√Eb, where Eb​ is the energy per bit. These signals represent binary 0 and 1.  BFSK (Binary FSK) Modulation: Transmits one of two signals: +√Eb​ ( On the y-axis, the phase shift of 90 degrees with respect to the x-axis, which is also termed phase offset ) or √Eb (on x-axis), where Eb​ is the energy per bit. These signals represent binary 0 and 1.  BPSK (Binary PSK) Modulation: Transmits one of two signals: +√Eb​ or -√Eb (they differ by 180 degree phase shift), where Eb​ is the energy per bit. These signals represent binary 0 and 1.  This article will primarily discuss constellation diagrams, as well as what constellation diagrams tell us and the significance of constellation diagrams. Constellation diagrams can often demonstrate how the amplitude and phase of signals or symbols differ. These two characteristics lessen the interference between t

Simulation of ASK, FSK, and PSK using MATLAB Simulink

ASK, FSK & PSK HomePage MATLAB Simulation Simulation of Amplitude Shift Keying (ASK) using MATLAB Simulink      In Simulink, we pick different components/elements from MATLAB Simulink Library. Then we connect the components and perform a particular operation.  Result A sine wave source, a pulse generator, a product block, a mux, and a scope are shown in the diagram above. The pulse generator generates the '1' and '0' bit sequences. Sine wave sources produce a specific amplitude and frequency. The scope displays the modulated signal as well as the original bit sequence created by the pulse generator. Mux is a tool for displaying both modulated and unmodulated signals at the same time. The result section shows that binary '1' is modulated by a certain sine wave amplitude of 1 Volt, and binary '0' is modulated by zero amplitude. Simulation of Frequency Shift Keying (FSK) using MATLAB Simulink   Result The diagram above shows t

Channel Impulse Response (CIR)

Channel Impulse Response (CIR) Wireless Signal Processing CIR, Doppler Shift & Gaussian Random Variable  The Channel Impulse Response (CIR) is a concept primarily used in the field of telecommunications and signal processing. It provides information about how a communication channel responds to an impulse signal.   What is the Channel Impulse Response (CIR) ? It describes the behavior of a communication channel in response to an impulse signal. In signal processing,  an impulse signal has zero amplitude at all other times and amplitude  ∞ at time 0 for the signal. Using a Dirac Delta function, we can approximate this.  ...(i) δ( t) now has a very intriguing characteristic. The answer is 1 when the Fourier Transform of  δ( t) is calculated. As a result, all frequencies are responded to equally by  δ (t). This is crucial since we never know which frequencies a system will affect when examining an unidentified one. Since it can test the system for all freq

How to use MATLAB Simulink

  MATLAB Simulink is a popular add-on of MATLAB. Here, you can use different blocks like modulator, demodulator, AWGN channel, etc. And you can do experiments on your own.       Steps Go to the 'Simulink' tab at the top navbar of MATLAB. If not found, click on the add-on tab, search 'Simulink,' and then click on it to add. Once you installed the simulation, click the 'new' tap at the top left corner. Then, search the required blocks in the 'Simulink library.' Then, drag it to the editor space. You can double-click on the blocks to see the input parameters Then, connect the blocks by dragging a line from one block's output terminal to another block's input. If the connection is complete, click the 'run' tab in the middle of the top navbar.   After clicking on the run button, your Simulink is ready. Then double-click on any block to see the output   The following block diagram is an example of the MATLAB simulation of 'QPSK'
document.onmouseup=new Function ("return false"); }