0% found this document useful (0 votes)
19 views5 pages

Lab Report2

Datacom Lab Report 2

Uploaded by

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

Lab Report2

Datacom Lab Report 2

Uploaded by

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

Title: Study of signal frequency, spectrum, bandwidth, and quantization using MATLAB

Abstract:
This experiment was designed to help understand the use of MATLAB for solving communication
engineering problems. This experiment also helps us develop the understanding of MATLAB
environment of MATLAB environment, commands and syntax.
Introduction:
i. Frequency:
The frequency of a wave describes how many waves go past a certain point in one
second. Frequency is measured in Hertz (usually abbreviated Hz), and can be calculated using
the formula:
V = fλ
where V is the velocity of the wave (in ms−1), f is the frequency of the wave (in Hz), and λ (the
Greek letter lambda) is the wavelength of the wave (distance from one peak / trough to the next,
in m). Frequency is the rate of change with respect to time. Change in a short span of time means
high frequency. Change over a long span of time means low frequency.
ii. Spectrum:
Usually we represent signals in time domain. But signals can be represented in
frequency domain as well. When signals are represented in frequency domain they are called
spectrum.
III. Bandwidth:
Bandwidth is the range of frequency a signal contains in it. If a composite signal is made up of
multiple sinusoids of 100, 250, 300, and 400 Hz. Then its bandwidth is the difference of the
highest and lowest frequency components. So here the bandwidth of the signal is (400-100) = 300
Hz
IV. Quantization:
The digitization of analog signals involves the rounding off of the values which are
approximately equal to the analog values. The method of sampling chooses a few points on the
analog signal and then these points are joined to round off the value to a near stabilized value.
Such a process is called as Quantization
2 0 - 4 2 1 3 7 - 1
A B C D E F G H
Therefore,
a1 = F + 1 => 3 + 1 = 4
a2 = G + 2 => 7 + 2 = 9
a3 = E + 3 => 1 + 3 = 4
f1 = E + 1 => 1 + 1 = 2
f2 = G + 2 => 7 + 2 = 9
f3 = F + 3 => 3 + 3 = 6
x1=a1*cos(2 *pi*f1* t) => 4*cos(2*pi*2*t)
x2=a2*sin(2*pi*f2*t); => 9*sin(2*pi*9*t)
x3=a3*cos(2*pi*f3*t); => 4*cos(2*pi*6*t)
Performance Task A: Time domain and frequency domain representations of signal_x in a single figure
window using subplot
Code:
fs = 8000; % Sampling frequency
t = 0:1/fs:2; % Time vector
% Amplitudes and frequencies based on given values
a1 = 4; % F + 1
a2 = 9; % G + 2
a3 = 4; % E + 3
f1 = 2; % E + 1
f2 = 9; % G + 2
f3 = 6; % F + 3
x1 = a1 * cos(2 * pi * f1 * t);
x2 = a2 * sin(2 * pi * f2 * t);
x3 = a3 * cos(2 * pi * f3 * t);
signal_x = x1 + x2 + x3;
nx = length(t);
% Plotting the time-domain representation
subplot(2,1,1);
plot(t, signal_x, 'linewidth', 1);
title('Time-Domain Representation of Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Frequency-domain representation using FFT
fftSignal = fft(signal_x);
fftSignal = fftshift(fftSignal) / (nx / 2);
f = linspace(-fs/2, fs/2, nx);
% Plotting the frequency-domain representation (magnitude)
subplot(2,1,2);
plot(f, abs(fftSignal), 'linewidth', 2);
title('Frequency-Domain Representation of Signal');
xlabel('Frequency (Hz)');
ylabel('Amplitude');
xlim([-20 20]);
Performance Task B : Quantize signal_x in 4 equally distributed levels and provide image for one cycle
of the original signal and quantized signal.
Code:
fs = 10000; % Sampling frequency
t = 0:1/fs:1;
f = 10;
a1 = 4; % F + 1
a2 = 9; % G + 2
a3 = 4; % E + 3
f1 = 2; % E + 1
f2 = 9; % G + 2
f3 = 6; % F + 3
% Generating the individual signals
x1 = a1 * cos(2 * pi * f1 * t);
x2 = a2 * sin(2 * pi * f2 * t);
x3 = a3 * cos(2 * pi * f3 * t);
% Composite signal
signal_x = x1 + x2 + x3;
% Quantization parameters
partition = -9.5:5:9.5; % Length 4, to represent 5 intervals
codebook = -10:4.5:10; % Length 5, one entry for each interval
% Quantize the signal
[index, quants] = quantiz(signal_x, partition, codebook);
% Plot the original and quantized signals
figure;
plot(t, signal_x, 'x', t, quants, '.');
legend('Original signal', 'Quantized signal');
title('Original and Quantized Signal');
xlabel('Time (s)');
ylabel('Amplitude');
Performance Task C: Quantize signal_x in 8 equally distributed levels and provide image for one cycle
of the original signal and quantized signal

Code:
a1 = 4;
a2 = 9;
a3 = 4;
f1 = 2;
f2 = 9;
f3 = 6;
bit_rate = 10000; % 10 kbps for consistency
pulse_duration = 1 / bit_rate;
samples_per_pulse = 500;
fs = samples_per_pulse / pulse_duration;
t = 0:1/fs:1;
x1 = a1 * cos(2 * pi * f1 * t);
x2 = a2 * sin(2 * pi * f2 * t);
x3 = a3 * cos(2 * pi * f3 * t);
signal_x = x1 + x2 + x3;
n = 8;
L = 2 * n;
delta = (max(signal_x) - min(signal_x)) / (L - 1);
xq = min(signal_x) + (round((signal_x - min(signal_x)) / delta)) * delta;
figure;
plot(t, signal_x, 'r-.', 'linewidth', 1.5);
hold on;
plot(t, xq, 'k-.', 'linewidth', 1.5);
xlabel('Time');
ylabel('Amplitude');
title('Example of Manual Quantization');
legend('Original signal', 'Quantized signal');

You might also like