IPCC- PRINCIPLES OF COMMUNICATION SYSTEMS- BEC402
PRINCIPLES OF COMMUNICATION SYSTEMS- BEC402
LAB MANUAL
FOR
IV SEMESTER B.E
VISHVESHWARAIAH TECHNOLOGICAL UNIVERSITY, BELAGAVI
DEPARTMENT OF ELECTRONICS AND TELECOMMUNICATION
ENGINEERING
SRI KRISHNA INSTITUTE OF TECHNOLOGY
BENGALURU-560090
Staff In-charge:
Radha G H,
Assistant Prof.
Dept. of Electronics &Communication Engineering,
SKIT, Bengaluru-90
Department of ECE
IPCC- PRINCIPLES OF COMMUNICATION SYSTEMS- BEC402
CONTENT LIST
SL. PAGE
EXPERIMENT NAME
NO. NO.
Basic Signals and Signal Graphing: a) Unit Step, b) Rectangular, c) standard
1. 1-6
triangle d) sinusoidal and e) Exponential signal.
Illustration of signal representation in time and frequency domains for a rectan
2. 7-8
pulse.
Amplitude Modulation and demodulation: Generation and display the
3. 9-10
relevant signals and its spectrums.
Frequency Modulation and demodulation: Generation and display the relevant 11-12
4.
signals and its spectrums.
Sampling and reconstruction of low pass signals. Display the signals and its
5. 13-14
spectrum.
6. Time Division Multiplexing and demultiplexing. 15-16
7. PCM Illustration: Sampling, Quantization and Encoding 17-18
Generate a)NRZ, RZ and Raised cosine pulse, b) Generate and plot eye 19-24
8.
diagram
9. Generate the Probability density function of Gaussian distribution function. 25
10. Display the signal and its spectrum of an audio signal. 26-27
Department of ECE
SKIT, Bengaluru-90
PRINCIPLES OF COMMUNICATION SYSTEMS- BEC402
PRACTICAL COMPONENT OF IPCC (Experiments conducted using MATLAB)
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');
Department of ECE BEC402-IPCC- PCS Lab Manual
1
SKIT, Bengaluru-90
OUTPUT:
% 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;
Department of ECE BEC402-IPCC- PCS Lab Manual
2
SKIT, Bengaluru-90
OUTPUT:
% 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');
Department of ECE BEC402-IPCC- PCS Lab Manual
3
SKIT, Bengaluru-90
OUTPUT:
% 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');
Department of ECE BEC402-IPCC- PCS Lab Manual
4
SKIT, Bengaluru-90
OUTPUT:
% e) Exponential Function%
clc;
clear all;
close all;
n=50;
s=0:1: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');
Department of ECE BEC402-IPCC- PCS Lab Manual
5
SKIT, Bengaluru-90
OUTPUT:
Department of ECE BEC402-IPCC- PCS Lab Manual
6
SKIT, Bengaluru-90
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;
Department of ECE BEC402-IPCC- PCS Lab Manual
7
SKIT, Bengaluru-90
OUTPUT:
Department of ECE BEC402-IPCC- PCS Lab Manual
8
SKIT, Bengaluru-90
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]);
Department of ECE BEC402-IPCC- PCS Lab Manual
9
SKIT, Bengaluru-90
OUTPUT:
Department of ECE BEC402-IPCC- PCS Lab Manual
10
SKIT, Bengaluru-90
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
Department of ECE BEC402-IPCC- PCS Lab Manual
11
SKIT, Bengaluru-90
Department of ECE BEC402-IPCC- PCS Lab Manual
12
SKIT, Bengaluru-90
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
Department of ECE BEC402-IPCC- PCS Lab Manual
13
SKIT, Bengaluru-90
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:
Department of ECE BEC402-IPCC- PCS Lab Manual
14
SKIT, Bengaluru-90
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
Department of ECE BEC402-IPCC- PCS Lab Manual
15
SKIT, Bengaluru-90
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
Department of ECE BEC402-IPCC- PCS Lab Manual
16
SKIT, Bengaluru-90
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);
Department of ECE BEC402-IPCC- PCS Lab Manual
17
SKIT, Bengaluru-90
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
Department of ECE BEC402-IPCC- PCS Lab Manual
18
SKIT, Bengaluru-90
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;
Department of ECE BEC402-IPCC- PCS Lab Manual
19
SKIT, Bengaluru-90
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
Department of ECE BEC402-IPCC- PCS Lab Manual
20
SKIT, Bengaluru-90
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:
Department of ECE BEC402-IPCC- PCS Lab Manual
21
SKIT, Bengaluru-90
% 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)]);
Department of ECE BEC402-IPCC- PCS Lab Manual
22
SKIT, Bengaluru-90
OUTPUT:
Raised Cosine Pulse Parameters:
Roll-off Factor: 0.5
Symbol Rate: 1 symbols/second
Span: 6 symbol periods
Samples per Symbol: 100
Department of ECE BEC402-IPCC- PCS Lab Manual
23
SKIT, Bengaluru-90
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:
Department of ECE BEC402-IPCC- PCS Lab Manual
24
SKIT, Bengaluru-90
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:
Department of ECE BEC402-IPCC- PCS Lab Manual
25
SKIT, Bengaluru-90
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;
Department of ECE BEC402-IPCC- PCS Lab Manual
26
SKIT, Bengaluru-90
OUTPUT:
Department of ECE BEC402-IPCC- PCS Lab Manual
27