DC Lab Manual
DC Lab Manual
The Gram-Schmidt process is used to convert a set of vectors into an orthogonal (or orthonormal) set of
vectors. Here's a MATLAB code snippet that implements the Gram-Schmidt process and plots the
orthonormal vectors.
% Number of vectors
n = size(A, 2);
% Gram-Schmidt process
for j = 1:n
v = A(:, j);
for i = 1:j-1
R(i, j) = Q(:, i)' * A(:, j);
v = v - R(i, j) * Q(:, i);
end
R(j, j) = norm(v);
Q(:, j) = v / R(j, j);
end
Output:
Orthonormal basis (Q):
0.5774 0.7071 -0.4082
0.5774 0 0.8165
0.5774 -0.7071 -0.4082
Explanation:
1. Input Matrix A: The matrix A contains the set of vectors as its columns.
2. Gram-Schmidt Process: The loop iterates over the vectors to orthogonalize them using
the Gram-Schmidt process. The result is stored in the matrix Q.
3. Plotting: The original vectors are plotted in black, while the orthonormal vectors
obtained from the Gram-Schmidt process are plotted in different colors.
Steps to Run:
1. Copy the code into a MATLAB script or the MATLAB command window.
2. Run the code. It will display the orthonormal vectors and plot them alongside the original
vectors.
You can replace the matrix A with any other set of vectors to test the code with different inputs.
Simulation of binary baseband signals using a rectangular pulse and estimate
the BER for AWGN channel using matched filter receiver.
To simulate binary baseband signals using a rectangular pulse and estimate the Bit Error Rate (BER) for
an Additive White Gaussian Noise (AWGN) channel using a matched filter receiver in MATLAB, you can
follow these steps. The code below performs this simulation:
% Parameters
T = 1; % Bit duration
for i = 1:length(SNR_dB)
% AWGN channel
sampled_signal = matched_filter(Fs:Fs:end);
end
figure;
xlabel('SNR (dB)');
grid on;
Explanation:
1. Parameters:
o N: Number of bits to transmit.
o T: Bit duration.
o Fs: Sampling frequency (number of samples per bit).
o SNR_dB: Range of Signal-to-Noise Ratio (SNR) values in dB to evaluate.
o M: Binary signaling (2 for BPSK).
2. Binary Data Generation:
o Random binary data is generated using randi.
3. Rectangular Pulse Shaping:
o The transmitted signal (tx_signal) is created by applying a rectangular pulse to
the binary data.
4. AWGN Channel:
o The awgn function simulates the effect of an AWGN channel on the transmitted
signal.
5. Matched Filter Receiver:
o A matched filter is applied by convolving the received signal with the time-
reversed rectangular pulse.
6. BER Calculation:
o The received signal is downsampled and thresholded to recover the binary data.
o The Bit Error Rate (BER) is calculated by comparing the received bits with the
original transmitted bits.
7. Plotting:
o The BER is plotted against the SNR in dB.
Steps to Run:
1. Copy the code into a MATLAB script or the MATLAB command window.
2. Run the code. It will simulate the transmission and reception of the binary baseband
signals, and plot the BER versus SNR curve.
This simulation provides a basic understanding of how binary baseband signals are transmitted
over an AWGN channel and received using a matched filter, with the BER being a key
performance metric.
Perform the QPSK Modulation and demodulation. Display the signal and
its constellation.
% Parameters
N = 1000; % Number of symbols
M = 4; % QPSK (4-ary modulation)
k = log2(M); % Bits per symbol
SNR_dB = 15; % Signal-to-noise ratio in dB
% QPSK Modulation
tx_signal = pskmod(data_symbols, M, pi/4);
% AWGN Channel
rx_signal = awgn(tx_signal, SNR_dB, 'measured');
% QPSK Demodulation
rx_symbols = pskdemod(rx_signal, M, pi/4);
Explanation:
1. Parameters:
o N: Number of symbols to transmit.
o M: The modulation order (4 for QPSK, since there are 4 possible symbol states).
o k: Bits per symbol (log2(M) gives 2 for QPSK).
o SNR_dB: The Signal-to-Noise Ratio in dB for the AWGN channel.
2. Data Generation:
o Random binary data is generated and reshaped into groups of 2 bits (since QPSK
modulates 2 bits per symbol).
3. QPSK Modulation:
o pskmod is used to perform QPSK modulation on the data symbols. A phase offset
of pi/4 is used to achieve the standard QPSK constellation.
4. AWGN Channel:
o The modulated signal is passed through an AWGN channel using awgn.
5. QPSK Demodulation:
o pskdemod is used to demodulate the received signal back to the original symbols.
6. BER Calculation:
o The demodulated data is compared with the original transmitted data to compute
the Bit Error Rate (BER).
7. Plotting:
o The modulated signal is plotted, showing the in-phase (I) and quadrature (Q)
components.
o The constellation diagram is displayed using scatterplot, showing the QPSK
constellation points.
Steps to Run:
1. Copy the code into a MATLAB script or the MATLAB command window.
2. Run the code. It will perform QPSK modulation, transmit the signal through an AWGN
channel, demodulate the signal, and display the modulated signal and its constellation
diagram.
This code provides a complete implementation of QPSK modulation and demodulation, along
with visualizations of the signal and its constellation, which are essential in understanding QPSK
communication systems.
Output:
Bit Error Rate (BER): 0
Generate 16-QAM Modulation and obtain the QAM
constellation.
% Parameters
N = 1000; % Number of symbols
M = 16; % 16-QAM (16-ary modulation)
k = log2(M); % Bits per symbol
SNR_dB = 20; % Signal-to-noise ratio in dB
% 16-QAM Modulation
tx_signal = qammod(data_symbols, M, 'UnitAveragePower', true);
% AWGN Channel (optional, can be removed if you only want the constellation)
rx_signal = awgn(tx_signal, SNR_dB, 'measured');
1. Parameters:
o N: Number of symbols to transmit.
o M: Modulation order (16 for 16-QAM, since there are 16 possible symbol states).
o k: Bits per symbol (log2(M) gives 4 for 16-QAM).
o SNR_dB: Signal-to-Noise Ratio in dB (optional for constellation visualization with
noise).
2. Data Generation:
o Random binary data is generated and reshaped into groups of 4 bits (since 16-
QAM modulates 4 bits per symbol).
3. Binary to Decimal Conversion:
o The binary groups are converted to decimal numbers ranging from 0 to 15, which
correspond to the 16-QAM symbol indices.
4. 16-QAM Modulation:
o qammod is used to perform 16-QAM modulation on the data symbols. The option
'UnitAveragePower', true normalizes the average power of the constellation
to 1.
5. AWGN Channel (Optional):
o The modulated signal is passed through an AWGN channel using awgn. This step
can be omitted if you only want to visualize the constellation without noise.
6. Constellation Plotting:
o The constellation diagram of the received signal is plotted using scatterplot.
o The transmitted signal points are also overlaid on the constellation diagram in red
for comparison.
Steps to Run:
1. Copy the code into a MATLAB script or the MATLAB command window.
2. Run the code. It will perform 16-QAM modulation and display the QAM constellation
diagram, optionally including the effects of an AWGN channel.
This code provides a clear visualization of the 16-QAM constellation, which is essential for
understanding the modulation scheme's signal space representation.