Skip to main content

Multi-User 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, ...

📘 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...

Constellation Diagram of ASK in Detail

A binary bit '1' is assigned a power level of E b \sqrt{E_b}  (or energy E b E_b ), while a binary bit '0' is assigned zero power (or no energy).   Simulator for Binary ASK Constellation Diagram SNR (dB): 15 Run Simulation Noisy Modulated Signal (ASK) Original Modulated Signal (ASK) Energy per bit (Eb) (Tb = bit duration): We know that all periodic signals are power signals. Now we’ll find the energy of ASK for the transmission of binary ‘1’. E b = ∫ 0 Tb (A c .cos(2П.f c .t)) 2 dt = ∫ 0 Tb (A c ) 2 .cos 2 (2П.f c .t) dt Using the identity cos 2 x = (1 + cos(2x))/2: = ∫ 0 Tb ((A c ) 2 /2)(1 + cos(4П.f c .t)) dt ...

Coherence Bandwidth and Coherence Time

🧮 Coherence Bandwidth 🧮 Coherence Time 🧮 MATLAB Code s 📚 Further Reading For Doppler Delay or Multi-path Delay Coherence time T coh ∝ 1 / v max (For slow fading, coherence time T coh is greater than the signaling interval.) Coherence bandwidth W coh ∝ 1 / Ï„ max (For frequency-flat fading, coherence bandwidth W coh is greater than the signaling bandwidth.) Where: T coh = coherence time W coh = coherence bandwidth v max = maximum Doppler frequency (or maximum Doppler shift) Ï„ max = maximum excess delay (maximum time delay spread) Notes: The notation v max −1 and Ï„ max −1 indicate inverse proportionality. Doppler spread refers to the range of frequency shifts caused by relative motion, determining T coh . Delay spread (or multipath delay spread) determines W coh . Frequency-flat fading occurs when W coh is greater than the signaling bandwidth. Coherence Bandwidth Coherence bandwidth is...

Online Simulator for ASK, FSK, and PSK

Try our new Digital Signal Processing Simulator!   Start Simulator for binary ASK Modulation Message Bits (e.g. 1,0,1,0) Carrier Frequency (Hz) Sampling Frequency (Hz) Run Simulation Simulator for binary FSK Modulation Input Bits (e.g. 1,0,1,0) Freq for '1' (Hz) Freq for '0' (Hz) Sampling Rate (Hz) Visualize FSK Signal Simulator for BPSK Modulation ...

MATLAB Code for ASK, FSK, and PSK

📘 Overview & Theory 🧮 MATLAB Code for ASK 🧮 MATLAB Code for FSK 🧮 MATLAB Code for PSK 🧮 Simulator for binary ASK, FSK, and PSK Modulations 📚 Further Reading ASK, FSK & PSK HomePage MATLAB Code MATLAB Code for ASK Modulation and Demodulation % The code is written by SalimWireless.Com % Clear previous data and plots clc; clear all; close all; % Parameters Tb = 1; % Bit duration (s) fc = 10; % Carrier frequency (Hz) N_bits = 10; % Number of bits Fs = 100 * fc; % Sampling frequency (ensure at least 2*fc, more for better representation) Ts = 1/Fs; % Sampling interval samples_per_bit = Fs * Tb; % Number of samples per bit duration % Generate random binary data rng(10); % Set random seed for reproducibility binary_data = randi([0, 1], 1, N_bits); % Generate random binary data (0 or 1) % Initialize arrays for continuous signals t_overall = 0:Ts:(N_bits...

Constellation Diagrams of ASK, PSK, and FSK

📘 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...

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

📘 Comparisons among ASK, FSK, and PSK 🧮 Online Simulator for calculating Bandwidth of ASK, FSK, and PSK 🧮 MATLAB Code for BER vs. SNR Analysis of ASK, FSK, and PSK 📚 Further Reading 📂 View Other Topics on Comparisons among ASK, PSK, and FSK ... 🧮 Comparisons of Noise Sensitivity, Bandwidth, Complexity, etc. 🧮 MATLAB Code for Constellation Diagrams of ASK, FSK, and PSK 🧮 Online Simulator for ASK, FSK, and PSK Generation 🧮 Online Simulator for ASK, FSK, and PSK Constellation 🧮 Some Questions and Answers 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 Parameters ASK FSK PSK Variable Characteristics Amplitude Frequency ...

Channel Impulse Response (CIR)

📘 Overview & Theory 📘 How CIR Affects the Signal 🧮 Online Channel Impulse Response Simulator 🧮 MATLAB Codes 📚 Further Reading What is the Channel Impulse Response (CIR)? 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. 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. Fig: Dirac Delta Function The result of this calculation is that all frequencies are responded to equally by δ(t) . This is crucial since we never know which frequenci...