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

Week - 3

Uploaded by

dpachaiappan16
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Week - 3

Uploaded by

dpachaiappan16
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Assignment – 2

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

PROGRAM :

% Define the number of data points

N = 1000; % number of data

% Define the size of the signal constellation

mlevel = 4; % size of signal constellation

% Calculate the number of bits per symbol

k = log2(mlevel); % number of bits per symbol

% Generate random binary bit stream of length N

x = randi([0 1], N, 1); % signal generation in bit stream

% Convert the bit stream into symbols using binary to decimal conversion

% Reshape the binary stream into a matrix with each column representing a symbol

% and each row representing a set of bits for each symbol

% 'left-msb' indicates that the most significant bit (MSB) is on the left side

xsym = bi2de(reshape(x,k, length(x)/k).', 'left-msb'); % convert the bit stream into symbol
stream

% Modulate the symbols using Quadrature Amplitude Modulation (QAM)

xmod = qammod(xsym, mlevel); % modulation

% Store the modulated symbols in a variable for transmission


Tx_x = xmod;

% Define the Signal-to-Noise Ratio (SNR) in decibels

SNR = 5;

% Add Additive White Gaussian Noise (AWGN) to the transmitted signal

Tx_awgn = awgn(Tx_x, SNR, 'measured'); % adding AWGN

% Store the received signal after noise addition

Rx_x = Tx_awgn; % Received signal

% Demodulate the received signal to recover the symbols

Rx_x_demod = qamdemod(Rx_x, mlevel); % demodulation

% Convert the demodulated symbols back to binary bits

z = de2bi(Rx_x_demod, 'left-msb'); % Convert integers to bits.

% Convert the matrix of bits back to a vector

Rx_x_BitStream = reshape(z.', prod(size(z)), 1); % Convert z from a matrix to a vector.

% Calculate the Bit Error Rate (BER) by comparing the transmitted and received bits

[number_of_errors, bit_error_rate] = biterr(x, Rx_x_BitStream); % Calculate BER

%display

disp(['Number of Errors:', num2str(number_of_errors)]);

disp(['Bit Error Rate (BER):', num2str(bit_error_rate)]);

% Plot each step of the process

subplot(5,2,[1 2]); stem(x(1:200),'filled'); title('Transmitted Bit Stream');

subplot(5,2,[3 4]); stem(xsym(1:50),'filled'); title('Transmitted Symbol');

subplot(5,2,5); plot(real(Tx_x), imag(Tx_x), 'go', 'MarkerFaceColor', [0, 1, 0]);

axis([-mlevel/2 mlevel/2 -mlevel/2 mlevel/2]);

subplot(5,2,6); plot(real(Rx_x), imag(Rx_x), 'go', 'MarkerFaceColor', [0, 1, 0]);


axis([-mlevel/2 mlevel/2 -mlevel/2 mlevel/2]);

subplot(5,2,[7 8]); stem(Rx_x_demod(1:50),'filled'); title('Received Symbol');

subplot(5,2,[9 10]); stem(Rx_x_BitStream(1:200),'filled'); title('Received BitStream');

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

% Assignment Questions:

% 1. Explore Multiple QAM (mlevel)

% 2. Explore the impact of mlevel on BER

% 3. Explore how Noise immunity differs with different mlevel values

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

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

OUTPUT:

You might also like