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.  

People are good at skipping over material they already know!

View Related Topics to







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 for a...

Power Spectral Density Calculation Using FFT in MATLAB

📘 Overview 🧮 Steps to calculate the PSD of a signal 🧮 MATLAB Codes 📚 Further Reading Power spectral density (PSD) tells us how the power of a signal is distributed across different frequency components, whereas Fourier Magnitude gives you the amplitude (or strength) of each frequency component in the signal. Steps to calculate the PSD of a signal Firstly, calculate the fast Fourier transform (FFT) of a signal. Then, calculate the Fourier magnitude (absolute value) of the signal. Square the Fourier magnitude to get the power spectrum. To calculate the Power Spectral Density (PSD), divide the squared magnitude by the product of the sampling frequency (fs) and the total number of samples (N). Formula: PSD = |FFT|^2 / (fs * N) Sampling frequency (fs): The rate at which the continuous-time signal is sampled (in ...

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 📚 Resources Definitions Constellation Tool Key Points MATLAB Code 📂 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 ...

DFTs-OFDM vs OFDM: Why DFT-Spread OFDM Reduces PAPR Effectively (with MATLAB Code)

DFT-spread OFDM (DFTs-OFDM) has lower Peak-to-Average Power Ratio (PAPR) because it "spreads" the data in the frequency domain before applying IFFT, making the time-domain signal behave more like a single-carrier signal rather than a multi-carrier one like OFDM. Deeper Explanation: Aspect OFDM DFTs-OFDM Signal Type Multi-carrier Single-carrier-like Process IFFT of QAM directly QAM → DFT → IFFT PAPR Level High (due to many carriers adding up constructively) Low (less fluctuation in amplitude) Why PAPR is High Subcarriers can add in phase, causing spikes DFT "pre-spreads" data, smoothing it Used in Wi-Fi, LTE downlink LTE uplink (as SC-FDMA) In OFDM, all subcarriers can...

ASK, FSK, and PSK (with MATLAB + Online Simulator)

📘 ASK Theory 📘 FSK Theory 📘 PSK Theory 📊 Comparison 🧮 MATLAB Codes 🎮 Simulator ASK or OFF ON Keying ASK is a simple (less complex) Digital Modulation Scheme where we vary the modulation signal's amplitude or voltage by the message signal's amplitude or voltage. We select two levels (two different voltage levels) for transmitting modulated message signals. Example: "+5 Volt" (upper level) and "0 Volt" (lower level). To transmit binary bit "1", the transmitter sends "+5 Volts", and for bit "0", it sends no power. The receiver uses filters to detect whether a binary "1" or "0" was transmitted. Fig 1: Output of ASK, FSK, and PSK modulation using MATLAB for a data stream "1 1 0 0 1 0 1 0" ( Get MATLAB Code ) ...

Online Simulator for ASK, FSK, and PSK

Try our new Digital Signal Processing Simulator!   •   Interactive ASK, FSK, and BPSK tools updated for 2025. Start Now Interactive Modulation Simulators Visualize binary modulation techniques (ASK, FSK, BPSK) in real-time with adjustable carrier and sampling parameters. 📡 ASK Simulator 📶 FSK Simulator 🎚️ BPSK Simulator 📚 More Topics ASK Modulator FSK Modulator BPSK Modulator More Topics Simulator for Binary ASK Modulation Digital Message Bits Carrier Freq (Hz) Sampling Rate (...

UGC NET Electronic Science Previous Year Question Papers

Home / Engineering & Other Exams / UGC NET 2022 PYQ 📥 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] UGC Net Paper 1 With Answer Key Download Pdf [Sep 2024] with full explanation ...