Skip to main content

BER vs SNR from Channel Impulse Response in MATLAB


In this MATLAB code it is described how to calculate 'BER vs SNR' and 'SER vs SNR' from the Channel Impulse Response (CIR)

SER =  Symbol error rate

For a typical communication system, if we transmit the signal x[n], then received signal will be,

y[n] = h[n]*x[n]  + noise

Where, h[n] is channel impulse response and '*' indicates convolution operation


MATLAB Code

clc;
clear all;
close all;

% Channel Impulse Response (CIR)
channel_response = [0.85]; % Example channel impulse response coefficients
%channel_response = [0.8, 0.1];
% Modulation parameters
modulation_order = 4; % QPSK modulation
num_symbols = 1000; % Number of symbols to transmit
num_bits = 1000*log2(modulation_order);

% Signal generation
tx_symbols = randi([0, modulation_order-1], 1, num_symbols);
tx_signal = qammod(tx_symbols, modulation_order);

% Channel simulation
rx_signal = conv(tx_signal, channel_response);

% Add AWGN (Additive White Gaussian Noise)
snr_dB = 0:2:20;
ber = zeros(size(snr_dB));

for i = 1:length(snr_dB)
noise_power = 10^(-snr_dB(i)/10);
rx_noisy_signal = rx_signal + sqrt(noise_power) * randn(size(rx_signal));

% Receiver processing
rx_symbols = qamdemod(rx_noisy_signal, modulation_order);

% BER calculation
a = reshape(de2bi(rx_symbols(1:num_symbols)),[1,num_bits]);
b = reshape(de2bi(tx_symbols),[1,num_bits]);

ber(i) = sum(a ~= b) / num_bits;
ser(i) = sum(rx_symbols(1:1000) ~= tx_symbols) / num_symbols;
end

% Plot BER vs. SNR curve
figure(1);
semilogy(snr_dB, ber, 'o-');
xlabel('SNR (dB)');
ylabel('Bit Error Rate (BER)');
title('BER vs. SNR');

grid on;

% Plot BER vs. SNR curve
figure(2);
semilogy(snr_dB, ser, 'o-');
xlabel('SNR (dB)');
ylabel('Symbol Error Rate (BER)');
title('SER vs. SNR');

grid on;

Output

 
 
 
 
 
 
 
 
Copy the aforementioned MATLAB Code from here 

People are good at skipping over material they already know!

View Related Topics to







Contact Us

Name

Email *

Message *

Popular Posts

Constellation Diagrams of ASK, PSK, and FSK with MATLAB Code + Simulator

📘 Overview of Energy per Bit (Eb / N0) 🧮 Online Simulator for constellation diagrams of ASK, FSK, and PSK 🧮 Theory behind Constellation Diagrams of ASK, FSK, and PSK 🧮 MATLAB Codes for Constellation Diagrams of ASK, FSK, and PSK 📚 Further Reading 📂 Other Topics on Constellation Diagrams of ASK, PSK, and FSK ... 🧮 Simulator for constellation diagrams of m-ary PSK 🧮 Simulator for constellation diagrams of m-ary QAM 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...

Fading : Slow & Fast and Large & Small Scale Fading (with MATLAB Code + Simulator)

📘 Overview 📘 LARGE SCALE FADING 📘 SMALL SCALE FADING 📘 SLOW FADING 📘 FAST FADING 🧮 MATLAB Codes 📚 Further Reading LARGE SCALE FADING The term 'Large scale fading' is used to describe variations in received signal power over a long distance, usually just considering shadowing.  Assume that a transmitter (say, a cell tower) and a receiver  (say, your smartphone) are in constant communication. Take into account the fact that you are in a moving vehicle. An obstacle, such as a tall building, comes between your cell tower and your vehicle's line of sight (LOS) path. Then you'll notice a decline in the power of your received signal on the spectrogram. Large-scale fading is the term for this type of phenomenon. SMALL SCALE FADING  Small scale fading is a term that describes rapid fluctuations in the received signal power on a small time scale. This includes multipath propagation effects as well as movement-induced Doppler fr...

Theoretical BER vs SNR for BPSK

Theoretical Bit Error Rate (BER) vs Signal-to-Noise Ratio (SNR) for BPSK in AWGN Channel Let’s simplify the explanation for the theoretical Bit Error Rate (BER) versus Signal-to-Noise Ratio (SNR) for Binary Phase Shift Keying (BPSK) in an Additive White Gaussian Noise (AWGN) channel. Key Points Fig. 1: Constellation Diagrams of BASK, BFSK, and BPSK [↗] BPSK Modulation Transmits one of two signals: +√Eb or −√Eb , where Eb is the energy per bit. These signals represent binary 0 and 1 . AWGN Channel The channel adds Gaussian noise with zero mean and variance N₀/2 (where N₀ is the noise power spectral density). Receiver Decision The receiver decides if the received signal is closer to +√Eb (for bit 0) or −√Eb (for bit 1) . Bit Error Rat...

Understanding the Q-function in BASK, BFSK, and BPSK

Understanding the Q-function in BASK, BFSK, and BPSK 1. Definition of the Q-function The Q-function is the tail probability of the standard normal distribution: Q(x) = (1 / √(2Ï€)) ∫ x ∞ e -t²/2 dt What is Q(1)? Q(1) ≈ 0.1587 This means there is about a 15.87% chance that a Gaussian random variable exceeds 1 standard deviation above the mean. What is Q(2)? Q(2) ≈ 0.0228 This means there is only a 2.28% chance that a Gaussian value exceeds 2 standard deviations above the mean. Difference Between Q(1) and Q(2) Even though the argument changes from 1 to 2 (a small increase), the probability drops drastically: Q(1) = 0.1587 → errors fairly likely Q(2) = 0.0228 → errors much rarer This shows how fast the tail of the Gaussian distribution decays. It’s also why BER drops drama...

BER vs SNR for M-ary QAM, M-ary PSK, QPSK, BPSK, ...(MATLAB Code + Simulator)

📘 Overview of BER and SNR 🧮 Online Simulator for BER calculation of m-ary QAM and m-ary PSK 🧮 MATLAB Code for BER calculation of M-ary QAM, M-ary PSK, QPSK, BPSK, ... 📚 Further Reading 📂 View Other Topics on M-ary QAM, M-ary PSK, QPSK ... 🧮 Online Simulator for Constellation Diagram of m-ary QAM 🧮 Online Simulator for Constellation Diagram of m-ary PSK 🧮 MATLAB Code for BER calculation of ASK, FSK, and PSK 🧮 MATLAB Code for BER calculation of Alamouti Scheme 🧮 Different approaches to calculate BER vs SNR 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. BER = (number of bits received in error) / (total number of tran...

Pulse Shaping using Raised Cosine Filter (with MATLAB + Simulator)

  MATLAB Code for Raised Cosine Filter Pulse Shaping clc; clear; close all ; %% ===================================================== %% PARAMETERS %% ===================================================== N = 64; % Number of OFDM subcarriers cpLen = 16; % Cyclic prefix length modOrder = 4; % QPSK oversample = 8; % Oversampling factor span = 10; % RRC filter span in symbols rolloff = 0.25; % RRC roll-off factor %% ===================================================== %% Generate Baseband OFDM Symbols %% ===================================================== data = randi([0 modOrder-1], N, 1); % Random bits txSymbols = pskmod(data, modOrder, pi/4); % QPSK modulation % IFFT to get OFDM symbol tx_ofdm = ifft(txSymbols, N); % Add cyclic prefix tx_cp = [tx_ofdm(end-cpLen+1:end); tx_ofdm]; %% ===================================================== %% Oversample the Baseband Signal %% ===============================================...

Envelope Detector Online Simulator

General Envelope Detector Simulator Modulation Type: AM (with carrier) PAM Message Frequency (fm): Hz Carrier Frequency (fc): Hz Carrier Amplitude (Ac): Modulation Index (m = Am / Ac): Envelope Detection and Amplitude-Based Modulations Envelope detectors are fundamental for amplitude-based modulations because they exploit the fact that the instantaneous amplitude of the carrier encodes the message signal . 1. Why Envelope Detection Works In amplitude modulation (AM), the modulated signal has the form: s(t) = [A_c + m(t)] cos(2Ï€ f_c t) A_c is the carrier amplitude m(t) is the message signal f_c is the carrier frequency The envelope of this waveform is: Envelope = |A_c + m(t)| . An envelope detector (e.g., a diode + RC circuit) follows the peaks of the ca...

Difference between AWGN and Rayleigh Fading

📘 Introduction, AWGN, and Rayleigh Fading 🧮 Simulator for the effect of AWGN and Rayleigh Fading on a BPSK Signal 🧮 MATLAB Codes 📚 Further Reading 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 (AWGN) in Wireless Channels , 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 coeffic...