MODELLING AND SIMULATION OF TDMA, FDMA AND TDMA FOR
WIRELESS COMMUNICATION
PROGRAM
% Parameters
num_users = 4; % Number of users
num_symbols = 100; % Number of symbols
% Generate random data bits for each user
data_bits = randi([0, 1], num_users, num_symbols);
% TDMA - Time Division Multiple Access
tdma_symbols = zeros(num_users, num_symbols);
for user = 1:num_users
tdma_symbols(user, :) = data_bits(user, :) * 2 - 1; % Convert 0s to -1s and 1s to 1s
end
% FDMA - Frequency Division Multiple Access
fdma_symbols = zeros(num_users, num_symbols);
for user = 1:num_users
fdma_symbols(user, :) = data_bits(user, :) * 2 - 1; % Convert 0s to -1s and 1s to 1s
end
% CDMA - Code Division Multiple Access
% Generating random spreading codes
spreading_codes = randi([0, 1], num_users, num_symbols);
cdma_symbols = zeros(num_users, num_symbols);
for user = 1:num_users
cdma_symbols(user, :) = (data_bits(user, :) * 2 - 1) .* spreading_codes(user, :);
end
% Plot TDMA, FDMA, and CDMA results
t = 1:num_symbols;
figure;
subplot(3, 1, 1);
plot(t, tdma_symbols', 'LineWidth', 1.5);
title('TDMA - Time Division Multiple Access');
xlabel('Symbol Index');
ylabel('Amplitude');
legend('User 1', 'User 2', 'User 3', 'User 4');
subplot(3, 1, 2);
plot(t, fdma_symbols', 'LineWidth', 1.5);
title('FDMA - Frequency Division Multiple Access');
xlabel('Symbol Index');
ylabel('Amplitude');
legend('User 1', 'User 2', 'User 3', 'User 4');
subplot(3, 1, 3);
plot(t, cdma_symbols', 'LineWidth', 1.5);
title('CDMA - Code Division Multiple Access');
xlabel('Symbol Index');
ylabel('Amplitude');
legend('User 1', 'User 2', 'User 3', 'User 4');
sgtitle('Modeling and Simulation of TDMA, FDMA, and CDMA for Wireless Communication');
OUTPUT
WIRELESS CHANNEL EQUALIZATION : ZERO FORCING
EQUALIZER(ZFE),MMSE EQUALIZER(MMSEE),ADAPTIVE
EQUALIZER(ADE),DECISION FEEDBACK EQUALIZER(DFE)
PROGRAM
a) ZERO FORCING EQUALIZER
% Zero Forcing Equalizer Parameters
channel_length = 10; % Length of the channel impulse response
channel_coefficients = [0.2, 0.5, 0.7, 0.3, 0.1, 0.4, 0.8, 0.6,0.9, 0.5]; % Channel coefficients
num_symbols = 1000; % Number of transmitted symbols
SNR_dB = 20; % Signal-to-Noise Ratio in dB
% Generate random data symbols (QPSK modulation)
data_symbols = 2 * randi([0, 1], 1, num_symbols) - 1;
% Apply channel distortion
channel_output = filter(channel_coefficients, 1, data_symbols);
% Add AWGN (Channel Modeling)
noise_power = 10^(-SNR_dB/10);
received_symbols = channel_output + sqrt(noise_power/2)*randn(size(channel_output));
% Zero Forcing Equalization
equalizer_tap = 1 / channel_coefficients(1); % One-tap ZeroForcing Equalizer
equalized_symbols = received_symbols * equalizer_tap;
equalized_bits = sign(equalized_symbols);
num_bit_errors = sum(data_symbols ~= equalized_bits);
bit_error_rate = num_bit_errors / num_symbols;
disp(['Bit Error Rate (BER): ', num2str(bit_error_rate)]);
disp(['SNR (dB):', num2str(SNR_dB)]);
OUTPUT
Bit Error Rate (BER): 0.476
SNR (dB):20
b)MMSE EQUALIZER
% Parameters
M = 4; % Number of transmitted symbols
N = 1000; % Number of received symbols
SNR_dB = 10;
pilot_Symbols = [1 -1 1 -1]; % Known pilot symbols
transmitted_Symbols = randi([0 M-1], 1, N);
modulated_Symbols = qammod(transmitted_Symbols, M);
channel = [0.8 -0.4 0.2 -0.1]; % Example channel coefficients
channel_Output = filter(channel, 1, modulated_Symbols);
SNR = 10^(SNR_dB/10);
noise_Var = 1/(2*SNR);
noise = sqrt(noise_Var) * randn(1, length(channel_Output));
received_Signal = channel_Output + noise;
% Channel estimation using pilot symbols
pilot_Indices = randperm(N, length(pilot_Symbols));
pilot_Signal = received_Signal(pilot_Indices);
estimated_Channel = conv(pilot_Signal, conj(pilot_Symbols(end:-1:1)));
estimated_Channel = estimated_Channel(end-length(channel)+1:end);
% MMSE equalization
equalizer_Coefficients = conj(estimated_Channel) ./ (abs(estimated_Channel).^2 + noise_Var);
equalized_Symbols = filter(equalizer_Coefficients, 1, received_Signal);
Demodulated_Symbols = qamde mod(equalized_Symbols, M);
bit_Errors = sum(transmitted_Symbols ~= demodulated_Symbols);
bit_Error_Rate = bit_Errors / N;
disp(['Bit Error Rate: ' num2str(bit_Error_Rate)]);
OUTPUT
Bit Error Rate: 0.787
C)ADAPTIVE EQUALIZER
% Adaptive Equalization Parameters
channel_length = 10; % Length of the channel impulse response
channel_coefficients = [0.2, 0.5, 0.7, 0.3, 0.1, 0.4, 0.8, 0.6,0.9, 0.5];
num_symbols = 1000; % Number of transmitted symbols
SNR_dB = 20; % Signal-to-Noise Ratio in dB
% Generate random data symbols (QPSK modulation)
data_symbols = 2 * randi([0, 1], 1, num_symbols) - 1;
% Apply channel distortion
channel_output = filter(channel_coefficients, 1, data_symbols);
% Add AWGN (Channel Modeling)
noise_power = 10^(-SNR_dB/10);
received_symbols = channel_output + sqrt(noise_power/2)*randn(size(channel_output));
% Adaptive Equalization using Recursive Least Squares (RLS)algorithm
equalizer_length = channel_length; % Choose equalizer length to be the same as the channel length
delta = 0.01; % Small positive constant to ensure numerical stability
forgetting_factor = 0.99; % Forgetting factor for RLS algorithm
equalizer = zeros(1, equalizer_length); % Initialize equalizer weights
P = (1/delta) * eye(equalizer_length); % Initialize inverse correlation matrix
equalized_symbols = zeros(1, num_symbols); % Store equalized symbols
for i = equalizer_length+1:num_symbols
observation = received_symbols(i:-1:i-equalizer_length+1); % extract current observation window
equalized_output = equalizer * observation.'; % apply equalizer to the observation
error = data_symbols(i) - equalized_output;
K = P * observation.' / (forgetting_factor + observation * P* observation.'); % calculate filter gain
equalizer = equalizer + K.' * error; % update equalizer weights
P = (1/forgetting_factor) * (P - K * observation * P); % update inverse correlation matrix
equalized_symbols(i) = equalized_output; % stored equalized symbol
end
equalized_bits = sign(equalized_symbols;
num_bit_errors = sum(data_symbols ~= equalized_bits);
bit_error_rate = num_bit_errors / num_symbols;
disp(['Bit Error Rate (BER): ', num2str(bit_error_rate)]);
disp(['SNR (dB): ', num2str(SNR_dB)]);
OUTPUT:
Bit Error Rate (BER): 0.449
SNR (dB): 20
D)DECISION FEEDBACK EQUALIZER
% Decision Feedback Equalization Parameters
channel_length = 10; % Length of the channel impulse response
channel_coefficients = [0.2, 0.5, 0.7, 0.3, 0.1, 0.4, 0.8, 0.6,0.9, 0.5]; % Channel coefficients
num_symbols = 1000; % Number of transmitted symbols
SNR_dB = 20; % Signal-to-Noise Ratio in dB
% Generate random data symbols (QPSK modulation)
data_symbols = 2 * randi([0, 1], 1, num_symbols) - 1;
channel_output = filter(channel_coefficients, 1, data_symbols); % apply channel distortion
% Add AWGN (Channel Modeling)
noise_power = 10^(-SNR_dB/10);
received_symbols = channel_output + sqrt(noise_power/2)
*randn(size(channel_output));
% Decision Feedback Equalization
equalizer_length = channel_length; % Choose equalizer length to be the same as the channel length
equalizer = zeros(1, equalizer_length); % Initialize equalizer weights
feedback = zeros(1, equalizer_length); % Initialize feedback coefficients
equalized_symbols = zeros(1, num_symbols); % Store equalized symbols
for i = equalizer_length+1:num_symbols
observation = received_symbols(i:-1:i-equalizer_length+1);
equalized_output = equalizer * observation.' - feedback *equalized_symbols(i-equalizer_length:i-1).';
equalized_symbols(i) = sign(equalized_output);
error = data_symbols(i) - equalized_symbols(i);
equalizer = equalizer + 2 * error * conj(observation);
feedback = feedback + 2 * error * conj(equalized_symbols(i-equalizer_length:i-1));
end
% Calculate Bit Error Rate (BER)
num_bit_errors = sum(data_symbols ~= equalized_symbols);
bit_error_rate = num_bit_errors / num_symbols;
disp(['Bit Error Rate (BER): ', num2str(bit_error_rate)]);
disp(['SNR (dB): ', num2str(SNR_dB)]);
OUTPUT:
Bit Error Rate (BER): 0.498
SNR (dB): 20