Skip to main content

Multi-User Alamouti STBC Implementation in MATLAB

 

MATLAB Code for Multi-User STBC (using Alamouti's Scheme) 

clc; clear;
% Parameters
N = 1e4; % Symbols per user
U = 2; % Number of users
SNR_dB = 0:5:30;
alpha = 0.8; % Modification factor
power = [0.7 0.3]; % Power allocation (sum <= 1)
% Generate QPSK symbols for each user
data = cell(U,1);
s1 = cell(U,1);
s2 = cell(U,1);
for u = 1:U
data{u} = randi([0 3], N, 2);
s = pskmod(data{u}, 4, pi/4);
s1{u} = s(:,1);
s2{u} = s(:,2);
end
% Channels (independent Rayleigh per user)
h1 = cell(U,1);
h2 = cell(U,1);
for u = 1:U
h1{u} = (randn(N,1)+1j*randn(N,1))/sqrt(2);
h2{u} = (randn(N,1)+1j*randn(N,1))/sqrt(2);
end
SER = zeros(length(SNR_dB),U);
% SNR loop
for k = 1:length(SNR_dB)
SNR = 10^(SNR_dB(k)/10);
noise_var = 1/SNR;
n1 = sqrt(noise_var/2)*(randn(N,1)+1j*randn(N,1));
n2 = sqrt(noise_var/2)*(randn(N,1)+1j*randn(N,1));
% Superposed transmission (all users)
x1 = zeros(N,1);
x2 = zeros(N,1);
for u = 1:U
x1 = x1 + sqrt(power(u))*s1{u};
x2 = x2 + sqrt(power(u))*s2{u};
end
% Reception per user
for u = 1:U
r1 = h1{u}.*x1 + h2{u}.*x2 + n1;
r2 = -alpha*h1{u}.*conj(x2) + h2{u}.*conj(x1) + n2;
% Alamouti combining
s1_hat = conj(h1{u}).*r1 + h2{u}.*conj(r2);
s2_hat = conj(h2{u}).*r1 - alpha*h1{u}.*conj(r2);
denom = abs(h1{u}).^2 + abs(h2{u}).^2;
s1_hat = s1_hat ./ denom;
s2_hat = s2_hat ./ denom;
% Detection
s1_dec = pskdemod(s1_hat/sqrt(power(u)), 4, pi/4);
s2_dec = pskdemod(s2_hat/sqrt(power(u)), 4, pi/4);
SER(k,u) = mean( ...
s1_dec ~= data{u}(:,1) | s2_dec ~= data{u}(:,2));
end
end
% Plot
figure;
semilogy(SNR_dB, SER(:,1),'o-', ...
SNR_dB, SER(:,2),'s-','LineWidth',2);
grid on;
xlabel('SNR (dB)');
ylabel('Symbol Error Rate');
legend('User 1','User 2');
title('Multi-User Modified Alamouti STBC');

 Output

 

 

  

After Applying Successive Interference Cancelling (SIC)

Successive Interference Cancellation (SIC)

In Successive Interference Cancellation (SIC), the receiver decodes the strongest signal first and then subtracts it from the received signal to reduce interference for the weaker signal. The received signal is a superposition of both users' signals:

        Received Signal = h1 * Signal1 + h2 * Signal2 + Noise
    

The receiver knows the modulation scheme (e.g., Frequency Modulation or QPSK), which allows it to decode the strongest signal. Once decoded, the receiver subtracts the strong signal from the mixture using the channel coefficient (h1). This leaves the weak user's signal with less interference, making it easier to decode the weak signal. Thus, SIC enables better reception of weaker signals by cancelling out the interference from stronger ones.

clc; clear;
% Parameters
N = 1e4; % Symbols per user
U = 2; % Number of users
SNR_dB = 0:5:30; % SNR values in dB
alpha = 0.8; % Modification factor
power = [0.7 0.3]; % Power allocation (sum <= 1)
% Generate QPSK symbols for each user
data = cell(U,1);
s1 = cell(U,1);
s2 = cell(U,1);
for u = 1:U
data{u} = randi([0 3], N, 2);
s = pskmod(data{u}, 4, pi/4);
s1{u} = s(:,1);
s2{u} = s(:,2);
end
% Channels (independent Rayleigh per user)
h1 = cell(U,1);
h2 = cell(U,1);
for u = 1:U
h1{u} = (randn(N,1) + 1j*randn(N,1)) / sqrt(2);
h2{u} = (randn(N,1) + 1j*randn(N,1)) / sqrt(2);
end
SER = zeros(length(SNR_dB), U);
% SNR loop
for k = 1:length(SNR_dB)
SNR = 10^(SNR_dB(k)/10); % Current SNR
noise_var = 1/SNR; % Noise variance
n1 = sqrt(noise_var/2)*(randn(N,1) + 1j*randn(N,1)); % Noise for signal 1
n2 = sqrt(noise_var/2)*(randn(N,1) + 1j*randn(N,1)); % Noise for signal 2
% Calculate SNR per user
snr_user = power ./ (noise_var * ones(1, U)); % SNR per user (using allocated power)
[~, user_order] = sort(snr_user, 'descend'); % Sort users by SNR (strongest first)
% Superposed transmission (all users)
x1 = zeros(N,1);
x2 = zeros(N,1);
for u = 1:U
x1 = x1 + sqrt(power(u)) * s1{u};
x2 = x2 + sqrt(power(u)) * s2{u};
end
% Reception per user with SIC
for u = 1:U
r1 = h1{u} .* x1 + h2{u} .* x2 + n1; % Received signal for user u
r2 = -alpha * h1{u} .* conj(x2) + h2{u} .* conj(x1) + n2; % Received signal for user u
% SIC Process: Decode strongest signal first
if u == user_order(1) % Strongest signal (first decoded)
% Decode user with strongest signal using Alamouti
s1_hat = conj(h1{u}) .* r1 + h2{u} .* conj(r2);
s2_hat = conj(h2{u}) .* r1 - alpha * h1{u} .* conj(r2);
denom = abs(h1{u}).^2 + abs(h2{u}).^2;
s1_hat = s1_hat ./ denom;
s2_hat = s2_hat ./ denom;
% Demodulate and detect symbols
s1_dec = pskdemod(s1_hat / sqrt(power(u)), 4, pi/4);
s2_dec = pskdemod(s2_hat / sqrt(power(u)), 4, pi/4);
SER(k,u) = mean(s1_dec ~= data{u}(:,1) | s2_dec ~= data{u}(:,2));
% Subtract the decoded signal contribution (interference removal)
x1 = x1 - sqrt(power(u)) * s1{u};
x2 = x2 - sqrt(power(u)) * s2{u};
end
end
% After strongest signal is decoded and subtracted, decode weaker signal(s)
for u = 2:U
if u == user_order(2) % Weaker signal (second decoded)
% Decode user with weaker signal (using Alamouti or other method)
r1 = h1{u} .* x1 + h2{u} .* x2 + n1;
r2 = -alpha * h1{u} .* conj(x2) + h2{u} .* conj(x1) + n2;
% Alamouti combining for weaker signal
s1_hat = conj(h1{u}) .* r1 + h2{u} .* conj(r2);
s2_hat = conj(h2{u}) .* r1 - alpha * h1{u} .* conj(r2);
denom = abs(h1{u}).^2 + abs(h2{u}).^2;
s1_hat = s1_hat ./ denom;
s2_hat = s2_hat ./ denom;
% Demodulate and detect symbols
s1_dec = pskdemod(s1_hat / sqrt(power(u)), 4, pi/4);
s2_dec = pskdemod(s2_hat / sqrt(power(u)), 4, pi/4);
SER(k,u) = mean(s1_dec ~= data{u}(:,1) | s2_dec ~= data{u}(:,2));
end
end
end
% Plot Symbol Error Rate (SER)
figure;
semilogy(SNR_dB, SER(:,1), 'o-', 'LineWidth', 2);
hold on;
semilogy(SNR_dB, SER(:,2), 's-', 'LineWidth', 2);
grid on;
xlabel('SNR (dB)');
ylabel('Symbol Error Rate');
legend('User 1', 'User 2');
title('Multi-User Modified Alamouti STBC with SIC');
 
 

Output 




Further Reading

  1.  

Contact Us

Name

Email *

Message *

Popular Posts

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

Bit Error Rate (BER) & SNR Guide Analyze communication system performance with our interactive simulators and MATLAB tools. 📘 Theory 🧮 Simulators 💻 MATLAB Code 📚 Resources BER Definition SNR Formula BER Calculator MATLAB Comparison 📂 Explore M-ary QAM, PSK, and QPSK Topics ▼ 🧮 Constellation Simulator: M-ary QAM 🧮 Constellation Simulator: M-ary PSK 🧮 BER calculation for ASK, FSK, and PSK 🧮 Approaches to BER vs SNR What is Bit Error Rate (BER)? The BER indicates how many corrupted bits are received compared to the total number of bits sent. It is the primary figure of merit f...

Online Simulator for ASK, FSK, and PSK

Interactive Digital Signal Processing (DSP) Tutorial and Simulator for ASK, FSK, and BPSK modulation techniques. Try our new Digital Signal Processing Simulator!   •   Interactive ASK, FSK, and BPSK tools updated for 2025. Start Now Digital Modulation Visualizer: ASK, FSK, & BPSK Simulator Learn and visualize binary modulation techniques (ASK, FSK, BPSK) in real-time with adjustable carrier and sampling parameters. Perfect for DSP students and engineers. 📡 ASK Simulator 📶 FSK Simulator 🎚️ BPSK Simulator 📚 More Topics ASK Modulator FSK Modulator BPSK Modulator More Topics 1. ASK (Amplitude Shift Keying) Simulat...

UGC NET Electronic Science Previous Year Question Papers with Solutions

Home / Engineering & Other Exams / UGC NET 2022 PYQ ⬇️ Download Papers and Solutions 📋 Exam Pattern 💡 Preparation Tips ❓ FAQs 📥 Download UGC NET Electronics PDFs Complete collection of previous year question papers, answer keys and explanations for Subject Code 88. Start Downloading UGC-NET (Electronics Science, Subject code: 88) Subject_Code : 88; Department : Electronic Science; 📂 View All Question Papers Q. UGC Net Electronic Science Question Paper [June 2025] A. UGC Net Electronic Science Question Paper With Answer Key Download Pdf [June 2025] with full explanation Q. UGC Net Electronic Science Question Paper [December 2024] A. UGC Net Electronic Science Question Paper With Answer Key Download Pdf [December 2024] ...

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

Constellation Diagrams: ASK, FSK, and PSK Comprehensive guide to signal space representation, including interactive simulators and MATLAB implementations. 📘 Overview 🧮 Simulator ⚖️ Theory Q-function 📚 Resources 📂 Other Topics: M-ary PSK & QAM Diagrams ▼ 🧮 Simulator for M-ary PSK Constellation 🧮 Simulator for M-ary QAM 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 phas...

1G to 5G Technology - Evolution of Wireless Generations

Cellular wireless evolution Generation Frequency band PHY features Data rate Spectral Eff. (bps/Hz) 1G 850 MHz FDMA, FM N/A N/A 2G 900 MHz, 1.8 GHz TDMA/CDMA, GMSK/QPSK, FEC, PC 10 Kbps < 1 3G 1.8–2.5 GHz CDMA, QAM 1–40 Mbps 1–8 4G 2–8 GHz OFDMA, SC-FDMA, QAM, MIMO-OFDM 100–600 Mbps 15 5G 1–6 GHz mm wave (26–28 GHz) < 1 GHz (massive IoT) visible light? massive MIMO, beamforming D2D, Full duplex, NOMA LDPC and Polar codes OFDM & variants (adapted to extremes?) multi-Gbps several tens Waveform design is the major change between the generations Mobile Wireless Generations Specifications  1G  Voice, Analog traffic, FDMA  2G  Voice, SMS, CS data ...

MATLAB Code for ASK, FSK, and PSK (with Online Simulator)

MATLAB Code for ASK, FSK, and PSK Comprehensive implementation of digital modulation and demodulation techniques with simulation results. 📘 Theory 📡 ASK Code 📶 FSK Code 🎚️ PSK Code 🕹️ Simulator 📚 Further Reading Amplitude Shift Frequency Shift Phase Shift Live Simulator ASK, FSK & PSK HomePage MATLAB Code MATLAB Code for ASK Modulation and Demodulation COPY % The code is written by SalimWireless.Com clc; clear all; close all; % Parameters Tb = 1; fc = 10; N_bits = 10; Fs = 100 * fc; Ts = 1/Fs; samples_per_bit = Fs * Tb; rng(10); binar...

BER performance of QPSK with BPSK, 4-QAM, 16-QAM, 64-QAM, 256-QAM, etc (MATLAB + Simulator)

📘 Overview 📚 QPSK vs BPSK and QAM: A Comparison of Modulation Schemes in Wireless Communication 📚 Real-World Example 🧮 MATLAB Code 📚 Further Reading   QPSK provides twice the data rate compared to BPSK. However, the bit error rate (BER) is approximately the same as BPSK at low SNR values when gray coding is used. On the other hand, QPSK exhibits similar spectral efficiency to 4-QAM and 16-QAM under low SNR conditions. In very noisy channels, QPSK can sometimes achieve better spectral efficiency than 4-QAM or 16-QAM. In practical wireless communication scenarios, QPSK is commonly used along with QAM techniques, especially where adaptive modulation is applied. Modulation Bits/Symbol Points in Constellation Usage Notes BPSK 1 2 Very robust, used in weak signals QPSK 2 4 Balanced speed & reliability 4-QAM ...

Q-function in BER vs SNR Calculation

Q-function in BER vs. SNR Calculation In the context of Bit Error Rate (BER) and Signal-to-Noise Ratio (SNR) calculations, the Q-function plays a significant role, especially in digital communications and signal processing . What is the Q-function? The Q-function is a mathematical function that represents the tail probability of the standard normal (Gaussian) distribution. Specifically, it is defined as: Q(x) = (1 / sqrt(2Ï€)) ∫â‚“∞ e^(-t² / 2) dt In simpler terms, the Q-function gives the probability that a standard normal random variable exceeds a value x . It is the complementary cumulative distribution function (CCDF) of the standard Gaussian distribution. The Role of the Q-function in BER vs. SNR The Q-function is the standard tool for calculating the Bit Error Rate (BER) in digital communication systems like Binary Phase Shift Keying (BPSK) or Quadrature Phase Shift Keying (QPSK) , where noise follows a Gaussian dis...