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

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

📘 Overview 📘 Amplitude Shift Keying (ASK) 📘 Frequency Shift Keying (FSK) 📘 Phase Shift Keying (PSK) 📘 Which of the modulation techniques—ASK, FSK, or PSK—can achieve higher bit rates? 🧮 MATLAB Codes 📘 Simulator for binary ASK, FSK, and PSK Modulation 📚 Further Reading 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. For 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. ...

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 🧮 MATLAB Code for BER calculation 📚 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 compared to the total number of bits sent. BER = (number of bits received in error) / (total number of transmitted bits) What is Signal-to-Noise Ratio (SNR)? SNR is the ratio of signal power to noise powe...

Calculation of SNR from FFT bins in MATLAB

📘 Overview 🧮 MATLAB Code for Estimation of SNR from FFT bins 🧮 MATLAB Code for SNR from PSD using Kaiser Window 📚 Further Reading Here, you can find the SNR of a received signal from periodogram / FFT bins using the Kaiser operator. The beta (β) parameter characterizes the Kaiser window, which controls the trade-off between the main lobe width and the side lobe level. Steps Set up the sampling rate and time vector Compute the FFT and periodogram Calculate the frequency resolution and signal power Exclude the signal power from noise calculation Compute the noise power and SNR MATLAB Code for Estimation of SNR from FFT bins clc; clear; close all; % Parameters fs = 8000; f_tone = 1000; N = 8192; t = (0:N-1)/fs; % Generate signal + noise signal = sin(2*pi*f_tone*t); SNR_true_dB = 20; signal_power = mean(signal.^2); noise_power = signal_power / (10^(SNR_true_dB/10)); noisy_signal = signal + sqrt(noise_power) * randn(1, N); % Apply ...

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

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

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

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

Comparing Baseband and Passband Implementations of ASK, FSK, and PSK

📘 Overview 🧮 Baseband and Passband Implementations of ASK, FSK, and PSK 🧮 Difference betwen baseband and passband 📚 Further Reading 📂 Other Topics on Baseband and Passband ... 🧮 Baseband modulation techniques 🧮 Passband modulation techniques   Baseband modulation techniques are methods used to encode information signals onto a baseband signal (a signal with frequencies close to zero). Passband techniques shift these signals to higher carrier frequencies for transmission. Here are the common implementations: Amplitude Shift Keying (ASK) [↗] : In ASK, the amplitude of the signal is varied to represent different symbols. Binary ASK (BASK) is a common implementation where two different amplitudes represent binary values (0 and 1). ASK is simple but susceptible to noise. ASK Baseband (Digital Bits) ASK Passband (Modulated Carrier)     Fig 1:  ASK Passband Modulation (...

LDPC Encoding and Decoding Techniques

📘 Overview & Theory 🧮 LDPC Encoding Techniques 🧮 LDPC Decoding Techniques 📚 Further Reading 'LDPC' is the abbreviation for 'low density parity check'. LDPC code H matrix contains very few amount of 1's and mostly zeroes. LDPC codes are error correcting code. Using LDPC codes, channel capacities that are close to the theoretical Shannon limit can be achieved.  Low density parity check (LDPC) codes are linear error-correcting block code suitable for error correction in a large block sizes transmitted via very noisy channel. Applications requiring highly reliable information transport over bandwidth restrictions in the presence of noise are increasingly using LDPC codes. 1. LDPC Encoding Technique The proper form of H matrix is derived from the given matrix by doing multiple row operations as shown above. In the above, H is parity check matrix and G is generator matrix. If you consider matrix H as [-P' | I] then matrix G will b...