DC Lab Manual
DC Lab Manual
PREPARED BY,
Shalini M G, Assistant Professor
Mahadev S, Assistant Professor
Dr. Sumaiya M N, Associate Professor
Dr. Banani Talukdar, Assistant Professor
Dept. of ECE,DASTM
Course Outcomes: At the end of the Course, the Student will be able to:
Design the basic digital modulation and demodulation circuits for different engineering
CO1
applications.
CO2 Design of optimum communication receivers for AWGN channels.
Illustration of different digital modulations using the signals and its equivalent vector
CO3 representations.
CO4 Implement the source coding and channel coding procedures using suitable software
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give
and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
Dept. of ECE,DASTM
Sl. LIST OF EXPERIMENTS
No
1 Generation and demodulation of the Amplitude Shift Keying signal.
4 Generation of DPSK signal and detection of data using DPSK transmitter and receiver.
6 Simulation of binary baseband signals using a rectangular pulse and estimate the BER
7 Perform the QPSK Modulation and demodulation. Display the signal and its
constellation.
11 For a given data, use the CRC-CCITT polynomial to obtain the CRC code. Verify for
Aim: To design and study the working of ASK modulation and demodulation system with
the help of suitable circuit
Specifications: M(t) = 10V, 500Hz, C(t) = 5V, 10KHz.
Equipment used:
BCLT-001 Trainer kit ---1
Theory:
1. Connect the AC Adaptor to the mains and the other side to the experimental trainer.
2. Observe the Bit Clock frequency on the Oscilloscope. Adjust the frequency to 10 KHz and
connect it to --.
3. Set the SPDP switches pattern to the desired code (say 0000 1111).
4. Parallel load by changing the switch to opposite side to shift side for a short duration and
get back to shift position.
5. Observe the 8 Bit word pattern at the output of the 8 Bit word generator. This is the actual
modulating signal.
6. Adjust the carrier frequency of ---- KHz and --- Volt p-p, give this input to the ASK
modulator inputs using a patch chord.
7. Connect the 8 Bit word generators output to the data input terminal of the ASK Modulator.
8. Observe the data input on one channel on a CRO and ASK output on the second channel.
9. To get demodulated signal, connect the ASK modulator output to demodulator input.
10. Adjust the two knobs simultaneously to get the original digital message at the demodulator
output on a CRO.
Pre-viva Questions:
1. State different types of Digital modulation techniques?
2. What is shift keying? What are applications of shift keying?
3. What is a binary modulation technique?
4. Define ASK?
Table : ASK Modulation & Demodulation (Amplitude & Frequency)
Dept. of ECE,DASTM
Expected Waveforms
Msg signal
150Hz, 5V
Carrier Signal
1 KHz, 5V
Modulated O/P
Demodulated
O/P
Results: ASK waveforms for different amplitude (1 - 10V) values of message signal verified
and found correct.
Conclusions: ASK setup is Implemented using ASK BCLT-001 Trainer kit and the
waveforms are validated and verified.
Experiment No 2
PSK generation and detection
Aim: To design and study the working of PSK modulation and demodulation using suitable circuit.
Theory:
Phase shift keying is one of the most efficient digital modulation techniques. It is used for very high bit rates. In
PSK, the phase of the carrier is modulated to represent Binary values. In BPSK, the carrier phase is used to
switch The phase between 00 and1800 by digital polar Format. Hence it is also known as phase reversal keying.
The modulated carrier is given by:
Binary 1: S (t) = Ac max. Cos. (2πfct)
Binary 0: S (t) = Ac max. Cos. (2πfct + 180)
= - Ac max. Cos. (2πfct)
Design:
For modulator :
VC= 5VP-P, Vm= 8Vp-p , fm= 100Hz, fc = 1khz,
Assume hfe=β= 50, Vbe(sat)=0.8V, Vce(sat)= 0.2V, Ic= 10 ma= Ie,
Vm(peak)= IcRc+Vce(sat)…i.e5= IbRb+0.8
Ib=4.2/RB (β=50, Rb=22kΩ(63kΩmax value));
Vc(peak)= IcRc+Vce(sat)+IeRe; Ie=Vc(p)- VCE(sat)/Re…i.e 1.8/Rc
Ib>Ic/β…i.e 4.2/RB>1.8/Rcβ
Assume Re=4.7kΩ therefore Rb=2.2kΩ
For demodulator:
1/fm >RC> 1/Fc1
3.3ms>RC>1ms
Let Rc= 2.2ms, C=0.2µf, R=10kΩ
Circuit Diagram:
Modulation:
Dept. of ECE,DASTM
Demodulation:
Procedure:
1) The connections are made as per the circuit diagram.
2) A sine wave of amplitude 5v and 2kHz is fed to the Collector of the transistor as carrier.
3) the message signal, a square wave of amplitude 5V and 150Hz is fed to the base of the transistor.
4) The BPSK wave is observed at pin 6 of the op-amp IC 741.
5) The demodulation circuit is also connected.
6) BPSK wave obtained is fed as input to the demodulation circuit.
7) The demodulated waveform is observed
8) All the required waveform to be plotted.
Waveforms:
Result:
Dept. of ECE,DASTM
Experiment No 3
FSK generation and detection
Aim:
To design and study the working of FSK modulation and demodulation with the help of a suitable circuit.
Theory:
As its name suggests, a frequency shift keyed transmitter has its frequency shifted by the message. Although
there could be more than two frequencies involved in an FSK signal, in this experiment the message will be a
binary bit stream, and so only two frequencies will be involved. The word „keyed‟ suggests that the message is
of the „on-off‟ (mark-space) variety, such as one (historically) generated by a morse key, or more likely in the
present context, a binary sequence. Conceptually, and in fact, the transmitter could consist of two oscillators (on
frequencies f1 and f2), with only one being connected to the output at any one time. Unless there are special
relationships between the two oscillator frequencies and the bit clock there will be abrupt phase discontinuities
of the output waveform during transitions of the message.
Bandwidth:
Practice is for the tones f1 and f2 to bear special inter-relationships, and to be integer multiples of the bit rate. This
leads to the possibility of continuous phase, which offers advantages, especially with respect to bandwidth control.
FSK signals can be generated at baseband, and transmitted over telephone lines (for example). In this case, both f1
and f2 (of Figure 2) would be audio frequencies. Alternatively, this signal could be translated to a higher frequency.
Yet again, it may be generated directly at carrier frequencies.
Design:
⮚ Modulator.
RC=VCC-VCE/(IC)=1kΩ
Vin− Vbe
RB= =10KΩ
Ib
⮚ Demodulator.
Low pass filter
fc=2KHz, C=0.1µf
1
fc=
2 πRC
R=7.9KΩ (Choose 10KΩ)
Envelope Detector.
1 1
≪ RC ≪
fm fc
fm=200Hz, fC=10KHz.
Hence C=0.1µf, and R=10KΩ
Circuit Diagram:
Procedure:
1. Rig up the modulator circuit as shown in the figure.
2. Apply carrier of amplitude 2 V(P- P) and frequency 1 kHz.
3. Apply carrier of amplitude 2 V(P- P) and frequency 2 kHz.
4. Apply message signal of amplitude 10 V(P - P) and frequency of 250 Hz. .
5. Observe ASK outputs at each collector of transistor, and also observe FSK output at pin 6 of op-amp.
6. Connect demodulator circuit.
7. Observe the demodulated output on CRO.
Waveforms:
Result:
Implement the following in C/C++/MATLAB/Scilab/Python or any other Suitable
software
4.Write a MATLAB program to encode binary data using Huffman code and decode it.
Aim: To write a MATLAB program to encode and decode binary data using Huffman code.
Theory:
Huffman coding is a widely used method for lossless data compression, named after David A. Huffman who
introduced it in 1952. It's a variable-length prefix coding algorithm used to compress data, where the most
frequent symbols are represented using shorter codes and the least frequent symbols are represented using
longer codes.
Encoding the information before transmission is necessary to ensure data security and efficient delivery of the
information. The MATLAB program presented here encodes and decodes the information and also outputs the
values of entropy, efficiency and frequency probabilities of characters present in the data stream.
Huffman algorithm is a popular encoding method used in electronics communication systems. It is widely used
in all the mainstream compression formats that you might encounter—from GZIP, PKZIP (winzip, etc) and
BZIP2, to image formats such as JPEG and PNG. Some programs use just the Huffman coding method, while
others use it as one step in a multistep compression process.
Huffman coding & deciding algorithm is used in compressing data with variable-length codes. The shortest
codes are assigned to the most frequent characters and the longest codes are assigned to infrequent characters.
Procedure:
PROGRAM
%Write a MATLAB based program for encoding and decoding of Huffman code% (variable length source
coding )
clc;clear all; close all;
symbol =[1:5]; % Distinct data symbols appearing in
p = [0.4 0.2 0.2 0.1 0.1]; % Probability of each data
[dict,avglen]=huffmandict(symbol,p)
samplecode = dict{5,2} % Codeword for fifth signal value dict{1,:}dict{2,:}dict{3,:}dict{4,:}dict{5,:}
hcode = huffmanenco(symbol,dict);
dhsig = huffmandeco(hcode,dict); % Decode the code.
disp('encoded msg:');
disp(hcode);
disp('decoded msg:');
disp(dhsig);
code_length=length(hcode)
sum=0;
for m=1:5
H=sum+(p(m)*log2(1/p(m)));
end
disp('H=');
disp(H);
Efficiency=(H/avglen)*100
Description
This program defines two functions: huffmanenco is used to encode data using the Huffman coding technique
based on a given Huffman dictionary. Huffman encoding replaces each symbol with its corresponding Huffman
codeword from the dictionary, resulting in a compressed representation of the data. and huffmandeco is used to
decode data that has been encoded using the Huffman coding technique, based on a given Huffman dictionary. It
takes the encoded data and the Huffman dictionary as input, returning the decoded data.
Output:
Manual verification:
Conclusion: Thus, Huffman coding efficiently represents the input data using variable-length codes, achieving
compression by using shorter codes for more frequent symbols.
5.Write a MATLAB program to encode binary data using a (7,4) Hamming code and
decode it.
Aim: To write a MATLAB program to encode binary data using a (7,4) Hamming code and decode it.
Theory: The (7,4) Hamming code is an error-correcting code that allows the correction of single-bit errors and
the detection of two-bit errors. It operates on 4 bits of data and adds 3 parity bits to form a 7-bit codeword.
Let's go through the steps to encode and decode a (7,4) Hamming code:
1. Data Preparation: Let's assume we have a 4-bit data sequence (D3, D2, D1, D0).
2. Calculate Parity Bits (P0, P1, P2):
● P0 is the parity bit for bits: D0, D1, D3
● P1 is the parity bit for bits: D0, D2, D3
● P2 is the parity bit for bits: D1, D2, D3
3. Insert Parity Bits: Place the calculated parity bits at their respective positions in the 7-bit codeword.
4. Form the Codeword: The codeword is now composed of the original 4 bits of data and the 3 parity bits.
Procedure:
Let's consider a 4-bit data: 1011 (D3, D2, D1, D0).
%Simulation for encoding and decoding of a [7,4] Hamming code. The decoder
%can correct one error as shown and as theory states. The table at the end
%of the file shows the various outputs with different error positions and
%message bits. One error can be placed at any of the 7 bit locations and
%corrections made.
clc;clear all; close all;
n = 7%# of codeword bits per block
k = 4%# of message bits per block
A = [ 1 1 1;1 1 0;1 0 1;0 1 1 ];%Parity submatrix-Need binary(decimal combination of 7,6,5,3)
G = [ eye(k) A ]%Generator matrix
H = [ A' eye(n-k) ]%Parity-check matrix
% ENCODER%
msg = [ 1 1 1 1 ] %Message block vector-change to any 4 bit sequence
code = mod(msg*G,2)%Encode message
% CHANNEL ERROR(add one error to code)%
%code(1)= ~code(1);
code(2)= ~code(2);
%code(3)= ~code(3);
%code(4)= ~code(4);%Pick one,comment out others
%code(5)= ~code(5);
%code(6)= ~code(6);
%code(7)= ~code(7);
recd = code %Received codeword with error
% DECODER%
syndrome = mod(recd * H',2)
%Find position of the error in codeword (index)
find = 0;
for ii = 1:n
if ~find
errvect = zeros(1,n);
errvect(ii) = 1;
search = mod(errvect * H',2);
if search == syndrome
find = 1;
index = ii;
end
end
end
disp(['Position of error in codeword=',num2str(index)]);
correctedcode = recd;
correctedcode(index) = mod(recd(index)+1,2)%Corrected codeword
%Strip off parity bits
msg_decoded=correctedcode;
msg_decoded=msg_decoded(1:4)
%Error position Syndrome Decimal 4 bit word codeword dmin
% 1 111 7 0000 0000000
% 2 110 6 0001 0001011 3
% 3 101 5 0010 0010101 4
% 4 011 3 0011 0011110 3
% 5 100 4 0100 0100110 3
% 6 010 2 0101 0101101 3
% 7 001 1 0110 0110011 4
%No error will give syndrome of 000 0111 0111000 3
% 1000 1000111 4
% 1001 1001100 3
% 1010 1010010 4
% 1011 1011001 3
% 1100 1100001 3
% 1101 1101010 3
% 1110 1110100 4
% 1111 1111111 3
%Any exclusive or additions of any two codewords should give another
%codeword.
In MATLAB, the eye function is used to create an identity matrix, which is a square matrix with ones on the
main diagonal and zeros elsewhere. Where n is the number of rows (and columns) in the resulting identity
matrix.
Output
n=
k=
G=
1 0 0 0 1 1 1
0 1 0 0 1 1 0
0 0 1 0 1 0 1
0 0 0 1 0 1 1
H=
1 1 1 0 1 0 0
1 1 0 1 0 1 0
1 0 1 1 0 0 1
msg =
1 1 1 1
code =
1 1 1 1 1 1 1
recd =
1 0 1 1 1 1 1
syndrome =
1 1 0
correctedcode =
1 1 1 1 1 1 1
msg_decoded =
1 1 1 1
Manual verification:
Conclusion: Thus a MATLAB program is written to encode and decode binary data using a (7,4) Hamming
code and results have been verified.
6.Write a MATLAB program to encode binary data using a ((3,1,2)/suitably designed) Convolution code
and decode it.
Aim: To write a program to encode binary data using a ((3,1,2)/suitably designed) Convolution code and decode
it.
Theory: Creating a complete MATLAB program for encoding and decoding using a specific convolutional code
requires a significant amount of code and understanding of the specific code parameters (rate, constraint length,
generator polynomials, etc.). I'll provide you with a general outline and steps to create the encoding and
decoding processes for a (3,1,2) convolutional code.
Procedure: let's define the generator polynomials for a (3,1,2) convolutional code:
Generator polynomials:
● g1=[1,0,1]
● g2=[1,1,1]
Encoding:
1. Define the input binary data.
2. Set up the convolutional code parameters (generator polynomials, rate, constraint length, etc.).
3. Use the convenc function to perform convolutional encoding on the input data.
Decoding:
1. Define the received encoded data (potentially with added noise or errors).
2. Set up the Viterbi decoder parameters (trellis structure, traceback depth, etc.).
3. Use the vitdec function to perform Viterbi decoding on the received encoded data.
% Display results
disp('Original Data:');
disp(input_data);
disp('Encoded Data:');
disp(encoded_data);
disp('Received Data:');
disp
In this example, convenc is used for encoding, and vitdec is used for decoding with a Viterbi decoder. Make
sure to adjust the input data, generator polynomials, and other parameters based on your specific requirements
for the convolutional code.
or
% Simulate channel noise (you can modify this based on your requirements)
noisy_encoded_bits = mod(encoded_bits + randi([0 1], size(encoded_bits)), 2);
% Display results
disp('Input Bits:');
disp(input_bits);
disp('Encoded Bits:');
disp(encoded_bits);
disp('Noisy Encoded Bits:');
disp(noisy_encoded_bits);
disp('Decoded Bits:');
disp(decoded_bits);
Manual verification:
Conclusion: Thus a MATLAB program is written to encode binary data using a ((3,1,2)/suitably designed)
Convolution code and decode it and results have been verified.
OUTPUT:
7.For a given data, use CRC-CCITT polynomial to obtain the CRC code. Verify the
program for the cases a) Without error b) With error
Aim: To obtain the CRC code for a given data using CRC-CCITT polynomial and to Verify the program for the
cases a) Without error b) With error
Theory: The cyclic redundancy check, or CRC, is a technique for detecting errors in digital data, but not for
making corrections when errors are detected. It is used primarily in data transmission.
This Cyclic Redundancy Check is the most powerful and easy to implement technique. CRC is based on binary
division. In CRC, a sequence of redundant bits, called cyclic redundancy check bits, are appended to the end of
data unit so that the resulting data unit becomes exactly divisible by a second, predetermined binary number. At
the destination, the incoming data unit is divided by the same number. If at this step there is no remainder, the
data unit is assumed to be correct and is therefore accepted. A remainder indicates that the data unit has been
damaged in transit and therefore must be rejected. The CCITT CRC-16 polynomial (used in a variety of
applications) is represented by the polynomial x16+x12+x5+1, which corresponds to the hex value 0x1021. We'll
create a MATLAB program to generate the CRC code for a given input data and then simulate both cases:
without error and with error in the received data.
Procedure:
1. Generate CRC for the given data using the CRC-CCITT polynomial.
2. Introduce an error in the data.
3. Recalculate CRC for the erroneous data.
4. Verify if the CRC detects the error.
crc=r(length(msg)+1:end)
frame = bitor(mseg,r)
OUTPUT:
CRC generation
Input Message sequence :[1 1 1 0 0 0 1 1]
Input Generator Polynomial :[1 1 0 0 1 1]
crc =
1 1 0 1 0
frame =
1 1 1 0 0 0 1 1 1 1 0 1 0
'1111000000000000'
sdd =
'1111000000000000000'
sdr =
'1101100111011010000'
scrc =
'110'
br =
'1101100111011110110'
In this program, bitshift is a MATLAB function that performs bitwise shifting on integer values. It shifts
the bits of an integer to the left or right by a specified number of positions. dec2bin is a MATLAB function
used to convert decimal (base-10) numbers to binary (base-2) representation.
Manual verification:
Conclusion: The CRC code is obtained for a given data using CRC-CCITT polynomial and the program is
verified for the cases a) Without error b) With error.
8.Gram-Schmidt Orthogonalization: To find orthogonal basis vectors for the given set of
vectors and plot the orthonormal vectors.
Aim: To write a MATLAB program to find orthogonal basis vectors for the given set of vectors and plot the
orthonormal vectors using Gram-Schmidt Orthogonalization.
% Program
clc;
clear all;
close all;
% Input matrix
A = [1 3; 4 -7; -1 -12];
% Initialize matrices
[rows, n] = size(A); % Dimensions of A
Q = zeros(rows, n); % Orthogonal matrix
QN = zeros(rows, n); % Orthonormal matrix
% Gram-Schmidt Process
for j = 1:n
v = A(:, j); % Start with the j-th column of A
for i = 1:j-1
% Projection of A(:,j) on Q(:,i)
rij = (Q(:, i)' * A(:, j)) / (Q(:, i)' * Q(:, i));
v = v - rij * Q(:, i); % Subtract projection
end
Q(:, j) = v; % Store orthogonal vector
QN(:, j) = v / norm(v); % Normalize to unit norm
end
disp('ortho =');
disp(orthogonality_check);
disp('orthonormal =');
disp(QN.' * QN); % Identity matrix for orthonormal vectors
Result
Input vector is
A=
1 3
4 -7
-1 -12
ortho =
4.2426 0
0 13.8784
orthonormal =
1.0000 0.0000
0.0000 1.0000
9. Perform the QPSK Modulation and demodulation. Display the signal and its
constellation
Program
% Modulation
M = 4; % Number of symbols
k = log2(M); % Number of bits per symbol
bits_per_symbol = length(data) / k;
data_reshaped = reshape(data, k, bits_per_symbol)';
symbol = bi2de(data_reshaped, 'left-msb')';
% Demodulation
demodulated_signal = pskdemod(rx_signal, M, pi/4); % Phase offset pi/4 for QPSK
numErrs = symerr(data,received_data)
subplot(2,1,2);
stem(received_data, 'linewidth', 2);
title('Received Data');
xlabel('Bit');
ylabel('Amplitude');
axis([0 length(received_data) 0 1.5]);
% Scatter plot
% Define demodulated symbols
demodulated_symbols = demodulated_signal; % Replace with your demodulated symbols
% Map demodulated symbols to complex constellation points
constellation_points = [1+1i, -1+1i, -1-1i, 1-1i]; % QPSK constellation points
figure()
scatter(real(constellation_points(demodulated_symbols+1)),
imag(constellation_points(demodulated_symbols+1)));
title('QPSK Constellation Diagram');
xlabel('In-phase Component');
ylabel('Quadrature Component');
axis([-2 2 -2 2]); % Adjust axis limits if needed
grid on;
Output:
11. Simulation of binary baseband signals using a rectangular pulse and estimate
the BER for AWGN channel using matched filter receiver
Aim of the Experiment: To simulate binary baseband signals using a rectangular pulse and estimate the BER
for AWGN channel using matched filter receiver.
Theory: Binary baseband signaling is the transmission of binary data (0s and 1s) over a communication channel
using a baseband signal, such as a rectangular pulse. Binary data is represented using a rectangular pulse
waveform. Each bit (0 or 1) is mapped to a signal with specific amplitude and duration. The rectangular pulse
serves as the carrier for transmitting binary information, providing a straightforward method for modulation in
baseband communication systems.
An Additive White Gaussian Noise (AWGN) channel models the real-world communication medium, where the
transmitted signal encounters random noise. AWGN is characterized by its constant power spectral density and Gaussian
amplitude distribution. The matched filter is a signal processing technique used at the receiver to maximize the signal-to-
noise ratio (SNR). It is designed to be the conjugate of the transmitted pulse, enabling optimal detection of binary symbols
in the presence of noise. The output of the matched filter is then sampled at the optimal time instants to decide the
transmitted bit. The BER quantifies the system's performance by measuring the ratio of incorrectly detected bits to the
total transmitted bits. For an AWGN channel, the theoretical BER can be derived and compared with simulated values to
validate system design and functionality.
Program code:
% Simplified Parameters
% Add AWGN
SNR = 10^(SNR_dB(snr_idx) / 10);
noise_power = 1 / (2 * SNR);
noise = sqrt(noise_power) * randn(length(tx_signal), 1);
rx_signal = tx_signal + noise;
% Matched Filter
matched_filter = rect_pulse;
filtered_signal = conv(rx_signal, matched_filter, 'same');
% Sample the output of the matched filter
sample_interval = round(length(filtered_signal) / N);
sampled_signal = filtered_signal(1:sample_interval:end);
Output:
12. Generate 16-QAM Modulation and obtain the QAM constellation.
Aim of the Experiment: To Generate 16-QAM Modulation and obtain the QAM constellation using
MATLAB.
Theory: Quadrature Amplitude Modulation (QAM) is a widely used digital modulation scheme in modern
communication systems. In QAM, two carrier waves, typically sinusoidal and orthogonal to each other, are
modulated in amplitude by the input signals. These two carriers correspond to the in-phase (I) and quadrature-
phase (Q) components, which combine to form a constellation of points in the complex plane. In 16-QAM,
the modulation order M=16, meaning it can represent 16 distinct symbols. Each symbol encodes 4 bits of
Program code:
clc;
clear all;
close all;
% Parameters
m = 16; % Modulation order (16-QAM)
k = log2(m); % Bits per symbol
n = 9000; % Total number of bits
n = k * floor(n / k); % Ensure n is a multiple of k
nsamp = 1; % Oversampling factor
% Generate random bit sequence
x = randi([0 1], n, 1); % Random binary sequence
figure;
stem(x(1:20), 'filled'); % Plot first 20 bits
title('Bit Sequence');
xlabel('Bit Index');
ylabel('Bit Amplitude');
% Convert bits to symbols
xsym = bi2de(reshape(x, k, length(x) / k).', 'left-msb'); % Group bits into symbols
figure;
stem(xsym(1:10), 'filled'); % Plot first 10 symbols
title('Symbol Plot');
xlabel('Symbol Index');
ylabel('Symbol Amplitude');
% Modulate using 16-QAM
y = qammod(xsym, m, 'UnitAveragePower', true); % Normalize power
ytx = y; % Transmitted signal
% Add AWGN to the signal
ebno = 10; % Eb/No in dB
snr = ebno + 10*log10(k) - 10*log10(nsamp); % Calculate equivalent SNR
yn = awgn(ytx, snr, 'measured'); % Add noise to the signal
% Received signal
yrx = yn;
% Scatter plot of transmitted and received signals
figure;
scatterplot(y); % Transmitted signal
title('Constellation diagram of Y');
figure;
scatterplot(yrx, 30); % Received signal with noise
title('Constellation diagram of Yrx');
Output: