0% found this document useful (0 votes)
5 views

Week - 5

Uploaded by

dpachaiappan16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Week - 5

Uploaded by

dpachaiappan16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Assignment – 4

Name Pachaiappan D
College Name Sri Ramanujar Engineering College
College Code 4123
Register number 412321106007
Assignment Week - 5

PROGRAM :

% Script for computing the Bit Error Rate (BER) for Binary Phase Shift Keying (BPSK)
modulation in a

% Rayleigh fading channel with 2 Transmitters (Tx) and 2 Receivers (Rx) MIMO channel,

% using Minimum Mean Square Error (MMSE) equalization.

clear; % Clear workspace variables

N = 10^6; % Number of bits or symbols

Eb_N0_dB = [0:15]; % Multiple Eb/N0 values in dB

nTx = 2; % Number of transmitters

nRx = 2; % Number of receivers

for ii = 1:length(Eb_N0_dB)

% Transmitter

% Generate random bit sequence for transmission

ip = rand(1, N) > 0.5; % Generating 0s and 1s with equal probability

s = 1 * ip - 1; % BPSK modulation: 0 -> -1; 1 -> 0

% Modulate the symbols for MIMO transmission

sMod = kron(s, ones(nRx, 1));

sMod = reshape(sMod, [nRx, nTx, N / nTx]);


% Generate Rayleigh fading channel

h = 1/sqrt(2) * [randn(nRx, nTx, N / nTx) + j * randn(nRx, nTx, N / nTx)];

% Generate white Gaussian noise with 0dB variance

n = 1/sqrt(2) * [randn(nRx, N / nTx) + j * randn(nRx, N / nTx)];

% Channel and noise addition

y = squeeze(sum(h .* sMod, 10)) + 10^(-Eb_N0_dB(ii) / 20) * n;

% Receiver

% Compute the MMSE equalization matrix: W = inv(H^H*H + sigma^2*I)*H^H

hCof = zeros(2, 2, N / nTx);

hCof(1, 1, :) = sum(h(:, 2, :) .* conj(h(:, 2, :)), 1) + 10^(-Eb_N0_dB(ii) / 10);

hCof(2, 2, :) = sum(h(:, 1, :) .* conj(h(:, 1, :)), 1) + 10^(-Eb_N0_dB(ii) / 10);

hCof(2, 1, :) = -sum(h(:, 2, :) .* conj(h(:, 1, :)), 1);

hCof(1, 2, :) = -sum(h(:, 1, :) .* conj(h(:, 2, :)), 1);

hDen = ((hCof(1, 1, :) .* hCof(2, 2, :)) - (hCof(1, 2, :) .* hCof(2, 1, :)));

hDen = reshape(kron(reshape(hDen, 1, N / nTx), ones(2, 2)), 2, 2, N / nTx);

hInv = hCof ./ hDen;

hMod = reshape(conj(h), nRx, N);

yMod = kron(y, ones(1, 2));

yMod = sum(hMod .* yMod, 1);

yMod = kron(reshape(yMod, 2, N / nTx), ones(1, 2));

yHat = sum(reshape(hInv, 2, N) .* yMod, 1);

% Receiver - hard decision decoding

ipHat = real(yHat) > 0;


% Counting the errors

nErr(ii) = size(find([ip - ipHat]), 2);

end

% Compute simulated BER

simBer = nErr / N;

% Compute theoretical BER for nRx=1 and nRx=2

EbN0Lin = 10 .^ (Eb_N0_dB / 10);

theoryBer_nRx1 = 0.5 * (1 - (1 + 1 ./ EbN0Lin) .^ (-0.5));

p = 1 / 2 - 1 / 2 * (1 + 1 ./ EbN0Lin) .^ (-1 / 2);

theoryBerMRC_nRx2 = p .^ 2 .* (1 + 2 * (1 - p));

% Plot BER curves

close all;

figure;

semilogy(Eb_N0_dB, theoryBer_nRx1, 'bp-', 'LineWidth', 2);

hold on;

semilogy(Eb_N0_dB, theoryBerMRC_nRx2, 'kd-', 'LineWidth', 2);

semilogy(Eb_N0_dB, simBer, 'mo-', 'LineWidth', 2);

axis([0 25 10^-5 0.5]);

grid on;

legend('Theory (nTx=2, nRx=2, ZF)', 'Theory (nTx=1, nRx=2, MRC)', 'Simulation (nTx=2,
nRx=2, MMSE)');

xlabel('Average Eb/No (dB)');

ylabel('Bit Error Rate');

title('BER for BPSK modulation with 2x2 MIMO and MMSE equalizer (Rayleigh channel)');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Assignment Questions:

% 1. Explore Multiple Eb/N0 ranges

% 2. Explore the impact of QPSK, 16-QAM on BER in MIMO

% 3. Explore how Noise immunity differs with different modulation schemes

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

By changing the different values in the program,we have a different output.

OUTPUT:

You might also like