Cambridge Institute of Technology, North Campus,
Kundana, International Airport Road, Bengaluru – 562110
LAB MANUAL
PRINCIPLE OF COMMUNICATION SYSTEMS (BEC402)
For
IV Semester ECE, CBCS Scheme of VTU
Prepared by
RUDRESH D H
Lab Instructor
Department Of ECE
Cambridge Institute of Technology – North Campus
TEMPLATE for IPCC (26.04.2022) Annexure-III
PRACTICAL COMPONENT OF IPCC (Experiments can be conducted using MATLAB/SCILAB/OCTAVE)
[Link] Experiments
1 Basic Signals and Signal Graphing: a) unit Step, b) Rectangular, c) standard triangle d) sinusoidal and e)
Exponential signal.
2 Illustration of signal representation in time and frequency domains for a rectangular pulse.
3 Amplitude Modulation and demodulation: Generation and display the relevant signals and its spectrums.
4
Frequency Modulation and demodulation: Generation and display the relevant signals and its spectrums.
5
Sampling and reconstruction of low pass signals. Display the signals and its spectrum.
6
Time Division Multiplexing and demultiplexing.
7
PCM Illustration: Sampling, Quantization and Encoding
8
Generate a)NRZ, RZ and Raised cosine pulse, b) Generate and plot eye diagram
9
Generate the Probability density function of Gaussian distribution function.
10 Display the signal and its spectrum of an audio signal.
Course outcomes (Course Skill Set):
At the end of the course, the student will be able to:
1. Understand the principles of analog communication systems and noise modelling.
2. Identify the schemes for analog modulation and demodulation and compare their performance.
3. Design of PCM systems through the processes sampling, quantization and encoding.
4. Describe the ideal condition, practical considerations of the signal representation for baseband transmission of
digital signals.
5. Identify and associate the random variables and random process in Communication system design.
Assessment Details (both CIE and SEE)
The weightage of Continuous Internal Evaluation (CIE) is 50% and for Semester End Exam (SEE) is 50%. The
minimum passing mark for the CIE is 40% of the maximum marks (20 marks out of 50) and for the SEE minimum
passing mark is 35% of the maximum marks (18 out of 50 marks). The student is declared as a pass in the course if
he/she secures a minimum of 40% (40 marks out of 100) in the sum total of the CIE (Continuous Internal Evaluation)
and SEE (Semester End Examination) taken together.
The IPCC means the practical portion integrated with the theory of the course. CIE marks for the theory component
are 25 marks and that for the practical component is 25 marks.
CIE for the theory component of the IPCC
• 25 marks for the theory component are split into 15 marks for two Internal Assessment Tests (Two Tests, each
of 15 Marks with 01-hour duration, are to be conducted) and 10 marks for other assessment methods
mentioned in 22OB4.2. The first test at the end of 40-50% coverage of the syllabus and the second test after
covering 85-90% of the syllabus.
• Scaled-down marks of the sum of two tests and other assessment methods will be CIE marks for the theory
component of IPCC (that is for 25 marks).
• The student has to secure 40% of 25 marks to qualify in the CIE of the theory component of IPCC.
3
TEMPLATE for IPCC (26.04.2022) Annexure-III
CIE for the practical component of the IPCC
• 15 marks for the conduction of the experiment and preparation of laboratory record, and 10 marks for the test
to be conducted after the completion of all the laboratory sessions.
• On completion of every experiment/program in the laboratory, the students shall be evaluated including viva-
voce and marks shall be awarded on the same day.
• The CIE marks awarded in the case of the Practical component shall be based on the continuous evaluation of
the laboratory report. Each experiment report can be evaluated for 10 marks. Marks of all experiments’ write-
ups are added and scaled down to 15 marks.
• The laboratory test (duration 02/03 hours) after completion of all the experiments shall be conducted for 50
marks and scaled down to 10 marks.
• Scaled-down marks of write-up evaluations and tests added will be CIE marks for the laboratory component of
IPCC for 25 marks.
• The student has to secure 40% of 25 marks to qualify in the CIE of the practical component of the IPCC.
SEE for IPCC
Theory SEE will be conducted by University as per the scheduled timetable, with common question papers for the
course (duration 03 hours)
1. The question paper will have ten questions. Each question is set for 20 marks.
2. There will be 2 questions from each module. Each of the two questions under a module (with a maximum of 3
sub-questions), should have a mix of topics under that module.
3. The students have to answer 5 full questions, selecting one full question from each module.
4. Marks scored by the student shall be proportionally scaled down to 50 Marks
The theory portion of the IPCC shall be for both CIE and SEE, whereas the practical portion will have a CIE
component only. Questions mentioned in the SEE paper may include questions from the practical
component.
• The minimum marks to be secured in CIE to appear for SEE shall be 10 (40% of maximum marks-25) in the
theory component and 10 (40% of maximum marks -25) in the practical component. The laboratory
component of the IPCC shall be for CIE only. However, in SEE, the questions from the laboratory component
shall be included. The maximum of 04/05 sub-questions are to be set from the practical component of IPCC,
the total marks of all questions should not be more than 20 marks.
• SEE will be conducted for 100 marks and students shall secure 35% of the maximum marks to qualify for
the SEE. Marks secured will be scaled down to 50.
• The student is declared as a pass in the course if he/she secures a minimum of 40% (40 marks out of 100)
in the sum total of the CIE (Continuous Internal Evaluation) and SEE (Semester End Examination) taken
together.
Suggested Learning Resources:
Books
1. Louis E Frenzel, Principles of Electronic Communication Systems, 3rd Edition, Mc Graw Hill Education
(India) Private Limited, 2016. ISBN: 978-0-07-066755-6.
2. Simon Haykin & Michael Moher, Communication Systems, 5th Edition, John Wiley, India Pvt. Ltd, 2010, ISBN:
978-81-265-2151-7.
Reference Books
4
TEMPLATE for IPCC (26.04.2022) Annexure-III
1. B P Lathi, Zhi Ding, “Modern Digital and Analog Communication Systems”, Oxford University Press., 4th
edition, 2010, ISBN: 97801980738002.
2. Herbert Taub, Donald L Schilling, Goutam Saha, “Principles of Communication systems”, 4th Edition, Mc
Graw Hill Education (India) Private Limited, 2016. ISBN: 978-1-25-902985-1
Web links and Video Lectures (e-Resources):
1. Principles of Communication Systems [Link]
2. Communication Engineering [Link]
Activity Based Learning (Suggested Activities in Class)/ Practical Based learning
1. Assignments and test – Knowledge level, Understand Level and Apply level
2. Experiential Learning by using free and open source software’s SCILAB or OCTAVE
3. Open ended questions by faculty, Open ended questions from students
5
1. Basic Signals and Signal Graphing: a) Unit Step, b) Rectangular, c) standard triangle d)
sinusoidal and e) Exponential signal.
AIM: To write a MATLAB program to generate basics signals as Unit Step,
Rectangular, Triangular, Sinusoidal, Exponential signal
% a) unit step function%
clc;
clear all;
close all;
% Define the time range
t = -5:0.01:5;
% Define the unit step function
unit_step = @(t) (t >= 0);
% Evaluate the unit step function
y = unit_step(t);
% Plot the unit step function
plot(t, y, 'LineWidth', 2);
xlabel('Time');
ylabel('Amplitude');
title('Unit Step Function');
grid on;
clc;
clear all;
close all;
N=100;
t=1:100;
x=ones(1,N);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('unit step function');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit step discrete function');
% b) unit rectangle function%
clc;
clear all;
close all;
% Define the time range
t = -5:0.01:5;
% Define the unit rectangle function
unit_rectangle = @(t) (abs(t) <= 0.5);
% Evaluate the unit rectangle function
y = unit_rectangle(t);
% Plot the unit rectangle function
plot(t, y, 'LineWidth', 2);
xlabel('Time');
ylabel('Amplitude');
title('Unit Rectangle Function');
grid on;
% c) triangular function%
clc;
clear all;
close all;
t=0:0.01:2;
x=sawtooth(2*pi*5*t,0.5);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('trianguler signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('triangular sequence');
% d) sinusoidal function%
clc;
clear all;
close all;
t=0:0.01:2;
x=sin(2*pi*t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sinusoidal signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('sinusoidal sequence');
% e) Exponential Function%
clc;
clear all;
close all;
n=50;
s=[Link]n;
figure(1)
C1=0.95*(exp(j*(pi/10)).*s);
C2=0.95*(exp(j*(pi/10)).*s);
C=real(C1)+real(C2);
stem(s, C)
xlabel('Sample Number n');
ylabel('Amplitude');
title('Exponential Signal');
2. Illustration of signal representation in time and frequency domains for a rectangular pulse
AIM: To write a MATLAB program to generate signal representation in time and frequency
domains for a rectangular pulse
% Illustration of Signal Representation in Time and Frequency Domains for a
Rectangular Pulse
clc;
clear all;
close all;
% Parameters
Fs = 1000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
duration = 1; % Duration of signal (seconds)
pulse_width = 0.1; % Width of rectangular pulse (seconds)
A = 1; % Amplitude
% Time vector
t = 0:T:duration-T;
% Generate rectangular pulse
x_rect = zeros(size(t));
x_rect(t < pulse_width) = A;
% Compute Fourier Transform
X_rect = fft(x_rect);
frequencies = linspace(0, Fs, length(X_rect));
% Plot the rectangular pulse in time domain
subplot(2, 1, 1);
plot(t, x_rect, 'b', 'LineWidth', 2);
title('Rectangular Pulse in Time Domain');
xlabel('Time (s)');
ylabel('Amplitude');
% Plot the magnitude of the Fourier Transform in frequency domain
subplot(2, 1, 2);
stem(frequencies, abs(X_rect), 'r', 'LineWidth', 2);
title('Magnitude of Fourier Transform in Frequency Domain');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
xlim([0, Fs/2]);
% Adjust plot
grid on;
OUTPUT:
3. Amplitude Modulation and demodulation: Generation and display the relevant signals and its
spectrums
AIM: To write a MATLAB program to generate Amplitude Modulation and demodulation and
display the relevant signals and its spectrums
% $$ %% AM Modulation and Demodulation using Functions in MATLAB
clc;
clear all;
close all;
%% Modulation index
h= 60;
%% Time Period of Simulation :
t = linspace(0, 0.2, 100000);
%% Message Signal :
Am = 14;
fm = 200;
ym = Am*cos(2*pi*fm*t);
figure;
subplot(4, 1, 1);
plot(t(1:10000), ym(1:10000));
title('Message Signal');
xlabel('time(t)');
ylabel('Amplitude');
%% Carrier Signal :
Ac = Am/h;
fc = 2000;
yc = Ac*cos(2*pi*fc*t);
subplot(4, 1, 2);
plot(t(1:10000), yc(1:10000));
title('Carrier Signal');
xlabel('time(t)');
ylabel('Amplitude');
%% Modulated Signal :
y = ammod(ym, fc, 100000, 0, Ac);
subplot(4, 1, 3);
plot(t(1:10000), y(1:10000));
title('Modulated Signal');
xlabel('time(t)');
ylabel('Amplitude');
%% Demodulated Signal :
z = amdemod(y, fc, 100000, 0, Ac);
subplot(4, 1, 4);
plot(t(1:10000), z(1:10000));
title('Demodulated Signal');
xlabel('time(t)');
ylabel('Amplitude');
ylim([-10, 10]);
OUTPUT:
4. Frequency Modulation and demodulation: Generation and display the relevant signals and its
spectrums
AIM: To write a MATLAB program to generate Frequency Modulation and demodulation and display
the relevant signals and its spectrums
clc;
clear all;
close all;
t = 0:0.001:1; %upto 1000 samples
vm = input('Enter Amplitude (Message) = ');
vc = input('Enter Amplitude (Carrier) = ');
fM = input('Enter Message frequency = ');
fc = input('Enter Carrier frequency = ');
m = input('Enter Modulation Index = ');
msg = vm*sin(2*pi*fM*t);
subplot(3,1,1); %plotting message signal
plot(t,msg);
xlabel('Time');
ylabel('Amplitude');
title('Message ');
carrier = vc*sin(2*pi*fc*t);
subplot(3,1,2); %plotting carrier signal
plot(t,carrier);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
y = vc*sin(2*pi*fc*t+m.*cos(2*pi*fM*t));
subplot(3,1,3); %plotting FM (Frequency Modulated) signal
plot(t,y);
xlabel('Time');
ylabel('Amplitude');
title('FM Signal');
OUTPUT:
Sample MATLAB Input:
Enter Amplitude (Message) = 5
Enter Amplitude (Carrier) = 5
Enter Message frequency = 8
Enter Carrier frequency = 100
Enter Modulation Index = 10
5. Sampling and reconstruction of low pass signals. Display the signals and its spectrum
AIM: To write a MATLAB program to generate Sampling and reconstruction of low pass
signals. Display the signals and its spectrum
% Sampling and Reconstruction of Low Pass Signals
clc;
clear all;
close all;
% Parameters
Fs = 1000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
duration = 1; % Duration of signal (seconds)
f_signal = 50; % Signal frequency (Hz)
A_signal = 1; % Signal amplitude
% Time vector
t = 0:T:duration-T;
% Generate low-pass signal
x = A_signal * sin(2*pi*f_signal*t);
% Plot original signal and its spectrum
figure;
subplot(2, 2, 1);
plot(t, x, 'b', 'LineWidth', 2);
title('Original Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Compute and plot spectrum of original signal
X = fft(x);
frequencies = linspace(0, Fs, length(X));
subplot(2, 2, 2);
plot(frequencies, abs(X), 'b', 'LineWidth', 2);
title('Spectrum of Original Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
xlim([0, Fs/2]);
% Sampling
Fs_new = 200; % New sampling frequency (Hz)
T_new = 1/Fs_new; % New sampling period
t_new = 0:T_new:duration-T_new;
x_sampled = A_signal * sin(2*pi*f_signal*t_new);
% Plot sampled signal and its spectrum
subplot(2, 2, 3);
stem(t_new, x_sampled, 'r', 'LineWidth', 2);
title('Sampled Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Compute and plot spectrum of sampled signal
X_sampled = fft(x_sampled);
frequencies_sampled = linspace(0, Fs_new, length(X_sampled));
subplot(2, 2, 4);
stem(frequencies_sampled, abs(X_sampled), 'r', 'LineWidth', 2);
title('Spectrum of Sampled Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
xlim([0, Fs_new/2]);
% Adjust plot
grid on;
OUTPUT:
6. Time Division Multiplexing and demultiplexing
AIM: To write a MATLAB program to generate Time Division Multiplexing and
demultiplexing
% Number of signals to multiplex
numSignals = 3;
% Number of time slots
numSlots = 10;
% Generate random data for each signal
data = cell(1, numSignals);
for i = 1:numSignals
data{i} = randi([0, 100], 1, numSlots); % Generate random data for each signal
end
% Multiplexing (combining signals into one)
TDM_signal = zeros(1, numSlots*numSignals);
for i = 1:numSignals
TDM_signal((i-1)*numSlots+1:i*numSlots) = data{i};
end
% Display multiplexed signal
disp('Multiplexed Signal (TDM):');
disp(TDM_signal);
% Demultiplexing (separating signals)
demux_data = cell(1, numSignals);
for i = 1:numSignals
demux_data{i} = TDM_signal(i:numSignals:end); % Extract every nth element
end
% Display demultiplexed signals
for i = 1:numSignals
fprintf('Demultiplexed Signal %d:\n', i);
disp(demux_data{i});
end
OUTPUT:
Multiplexed Signal (TDM):
Columns 1 through 20
10 97 0 78 82 87 8 40 26 80 43 91 18 26 14 13 87 58 55 14
Columns 21 through 30
86 62 35 51 40 7 24 12 18 24
Demultiplexed Signal 1:
10 78 8 80 18 13 55 62 40 12
Demultiplexed Signal 2:
97 82 40 43 26 87 14 35 7 18
Demultiplexed Signal 3:
0 87 26 91 14 58 86 51 24 24
7. PCM Illustration: Sampling, Quantization and Encoding
AIM: To write a MATLAB program to generate PCM Illustration: Sampling, Quantization and
Encoding
% PCM Illustration: Sampling, Quantization, and Encoding
% Parameters
Fs = 1000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
t = 0:T:1-T; % Time vector for one second
% Analog signal (example: sine wave)
Analog_signal = sin(2*pi*5*t); % 5 Hz sine wave
% Plot analog signal
subplot(3,1,1);
plot(t, Analog_signal);
title('Analog Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Sampling
nSamples = 10; % Number of samples
sampled_signal = Analog_signal(1:nSamples); % Downsample
% Plot sampled signal
stem((0:(nSamples-1))*T, sampled_signal);
title('Sampled Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Quantization
nBits = 4; % Number of bits for quantization
quantized_signal = round(sampled_signal * (2^(nBits-1) - 1));
% Plot quantized signal
subplot(3,1,3);
stem((0:nSamples-1)*T, quantized_signal);
title('Quantized Signal');
xlabel('Time (s)');
ylabel('Quantization Levels');
% Encoding (converting to binary)
binary_signal = de2bi(quantized_signal, nBits, 'left-msb');
% Display encoded signal
disp('Encoded Signal (Binary):');
disp(binary_signal);
OUTPUT:
Encoded Signal (Binary):
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 1
0 0 0 1
0 0 0 1
0 0 0 1
0 0 1 0
0 0 1 0
0 0 1 0
8. Generate a) NRZ, RZ and Raised cosine pulse, b) Generate and plot eye diagram
% MATLAB Program to Generate and Plot an NRZ Signal
% Define the binary data sequence
data = [1 0 1 1 0 0 1 0 1]; % Example binary sequence
% Parameters for the signal
bit_rate = 1; % bits per second
bit_duration = 1 / bit_rate; % duration of one bit in seconds
samples_per_bit = 100; % number of samples per bit
% Time vector for one bit
t_bit = linspace(0, bit_duration, samples_per_bit);
% Initialize the NRZ signal vector
nrz_signal = [];
% Generate the NRZ signal
for bit = data
if bit == 1
nrz_signal = [nrz_signal ones(1, samples_per_bit)];
else
nrz_signal = [nrz_signal zeros(1, samples_per_bit)];
end
end
% Time vector for the entire signal
t = linspace(0, bit_duration * length(data), length(nrz_signal));
% Plot the NRZ signal
figure;
plot(t, nrz_signal, 'LineWidth', 2);
ylim([-0.5 1.5]);
xlabel('Time (s)');
ylabel('Amplitude');
title('NRZ Signal');
grid on;
OUTPUT:
% MATLAB Program to Generate and Plot an RZ Signal
% Define the binary data sequence
data = [1 0 1 1 0 0 1 0 1]; % Example binary sequence
% Parameters for the signal
bit_rate = 1; % bits per second
bit_duration = 1 / bit_rate; % duration of one bit in seconds
samples_per_bit = 100; % number of samples per bit
half_bit_samples = samples_per_bit / 2; % samples for half bit duration
% Time vector for one bit
t_bit = linspace(0, bit_duration, samples_per_bit);
% Initialize the RZ signal vector
rz_signal = [];
% Generate the RZ signal
for bit = data
if bit == 1
rz_signal = [rz_signal ones(1, half_bit_samples) zeros(1, half_bit_samples)];
else
rz_signal = [rz_signal zeros(1, samples_per_bit)];
end
end
% Time vector for the entire signal
t = linspace(0, bit_duration * length(data), length(rz_signal));
% Plot the RZ signal
figure;
plot(t, rz_signal, 'LineWidth', 2);
ylim([-0.5 1.5]);
xlabel('Time (s)');
ylabel('Amplitude');
title('RZ Signal');
grid on;
OUTPUT:
% MATLAB Program to Generate and Plot a Raised Cosine Pulse
% Parameters
rolloff = 0.5; % Roll-off factor (0 <= rolloff <= 1)
symbol_rate = 1; % Symbol rate (symbols per second)
span = 6; % Number of symbol periods the pulse spans
samples_per_symbol = 100; % Number of samples per symbol
% Derived parameters
Fs = samples_per_symbol * symbol_rate; % Sampling frequency
Ts = 1 / symbol_rate; % Symbol duration
% Time vector
t = linspace(-span/2, span/2, span * samples_per_symbol);
% Raised Cosine Pulse Generation
raised_cosine_pulse = zeros(size(t));
for i = 1:length(t)
if abs(t(i)) == Ts / (2 * rolloff)
raised_cosine_pulse(i) = (pi/4) * sinc(1/(2*rolloff));
elseif abs(t(i)) < Ts / (2 * rolloff)
raised_cosine_pulse(i) = sinc(t(i) / Ts) * cos(pi * rolloff * t(i) / Ts) / (1 - (2 * rolloff *
t(i) / Ts)^2);
else
raised_cosine_pulse(i) = 0;
end
end
% Plot the Raised Cosine Pulse
figure;
plot(t, raised_cosine_pulse, 'LineWidth', 2);
xlabel('Time (s)');
ylabel('Amplitude');
title(['Raised Cosine Pulse (Roll-off Factor = ', num2str(rolloff), ')']);
grid on;
% Display the pulse properties
disp('Raised Cosine Pulse Parameters:');
disp(['Roll-off Factor: ', num2str(rolloff)]);
disp(['Symbol Rate: ', num2str(symbol_rate), ' symbols/second']);
disp(['Span: ', num2str(span), ' symbol periods']);
disp(['Samples per Symbol: ', num2str(samples_per_symbol)]);
OUTPUT:
Raised Cosine Pulse Parameters:
Roll-off Factor: 0.5
Symbol Rate: 1 symbols/second
Span: 6 symbol periods
Samples per Symbol: 100
b) Generate and plot eye diagrams
% Generate a random binary signal
data_length = 1000;
data = randi([0, 1], 1, data_length);
% Reshape the data into a matrix with desired number of samples per symbol
samples_per_symbol = 10;
num_symbols = data_length / samples_per_symbol;
eye_data = reshape(data, samples_per_symbol, num_symbols);
% Plot the eye diagram
figure;
plot(eye_data);
title('Eye Diagram');
xlabel('Sample');
ylabel('Amplitude');
grid on;
OUTPUT:
9. Generate the Probability density function of Gaussian distribution function
AIM: To write a MATLAB program to generate the Probability density function of Gaussian
distribution function
% Parameters
mu = 0; % Mean of the Gaussian distribution
sigma = 1; % Standard deviation of the Gaussian distribution
% Define range for x-axis
x = -5:0.1:5;
% Compute PDF
pdf = (1 / (sigma * sqrt(2 * pi))) * exp(-(x - mu).^2 / (2 * sigma^2));
% Plot PDF
figure;
plot(x, pdf, 'b', 'LineWidth', 2);
title('Probability Density Function of Gaussian Distribution');
xlabel('x');
ylabel('PDF');
grid on;
OUTPUT:
10. Display the signal and its spectrum of an audio signal
AIM: To write a MATLAB program to generate the signal and its spectrum of an audio signal
% Load audio file
audioFile = 'your_audio_file.wav'; % Change this to your audio file path
[y, Fs] = audioread(audioFile);
% Plot the time-domain signal
t = (0:length(y)-1) / Fs;
figure;
subplot(2, 1, 1);
plot(t, y);
title('Time-Domain Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Compute the spectrum
N = length(y);
Y = fft(y);
f = (0:N-1) * Fs / N;
% Plot the spectrum
subplot(2, 1, 2);
plot(f, abs(Y));
title('Frequency Spectrum');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
xlim([0, Fs/2]); % Display only positive frequencies
% You can also use the following line to display the spectrum in dB scale
% plot(f, 20*log10(abs(Y)));
% ylabel('Magnitude (dB)');
% Adjust plot
grid on;
OUTPUT: