You are on page 1of 11

Assignment No.

2
Communication Systems

Submitted to:
Sir Dr. Engr. Muhammad
Saleem

Submitted by:
Haseeb Ahmed
ELEN-201101071
Assignment No.2 (CLO-2)
Question No.1: Analyze the audio file using MATLAB Tool as?
Task 1: Read audio file
Task 2: Quantize audio signal
Task 3: Compute SNR
Private Functions
Answer. Following is the MATLAB Code:

% Task 1: Read audio file


filename = 'audio.wav'; % Provide the path to your audio file
[audio, fs] = audioread(filename);

% Task 2: Quantize audio signal


bits = 8; % Number of bits for quantization
quantized_audio = quantize(audio, bits);

% Task 3: Compute SNR


noise = audio - quantized_audio;
signal_power = sum(audio.^2) / length(audio);
noise_power = sum(noise.^2) / length(noise);
snr = 10 * log10(signal_power / noise_power);

% Private Functions
function quantized_signal = quantize(signal, bits)
% Normalize the signal to the range [-1, 1]
max_value = max(abs(signal));
normalized_signal = signal / max_value;

% Quantize the normalized signal


quantization_levels = 2^bits;
quantized_signal = round(normalized_signal * (quantization_levels-1));

% Scale the quantized signal back to the original range


quantized_signal = quantized_signal / (quantization_levels-1) * max_value;
end

In this code, replace 'audio.wav' with the actual path to your audio file. Make sure the audio file
is in a format supported by MATLAB (e.g., WAV, MP3).

The code reads the audio file using the audioread function and stores the audio samples in the
audio variable. The sample rate is stored in the fs variable.

Next, the quantize function quantizes the audio signal using a specified number of bits. The
quantization is done by normalizing the signal to the range [-1, 1], quantizing it to the desired
number of levels, and then scaling it back to the original range.
Finally, the code computes the signal-to-noise ratio (SNR) by calculating the power of the
original audio signal and the power of the quantization noise. The SNR is expressed in decibels
(dB) using the formula SNR = 10 * log10(signal_power / noise_power).

Question No.2: Analyze the following topics in term of wireless communication systems:
1. Block chain-based Communication
2. SD Radio for 5G
3. Broadband Communication
Answer.
1. Block chain-based Communication:
Block chain technology has the potential to impact wireless communication systems in
several ways. Block chain can provide secure and transparent communication between
devices and networks by decentralizing trust and eliminating the need for intermediaries.
Some potential applications of block chain-based communication in wireless systems
include:
 Secure and private messaging: Block chain can enable encrypted and decentralized
messaging systems that ensure the privacy and integrity of communication between
wireless devices.
 Identity and authentication: Block chain can provide a decentralized identity
management system, allowing devices to securely authenticate and interact with each
other.
 Resource sharing and billing: Block chain can facilitate peer-to-peer resource sharing
and enable transparent and automated billing and payment mechanisms for wireless
services.
 Spectrum management: Block chain can be used to create decentralized spectrum
sharing systems, where devices negotiate and allocate spectrum resources autonomously
and efficiently.

2. SD Radio for 5G:


Software-Defined Radio (SDR) is a technology that allows wireless communication
systems to be flexible and adaptable by separating the hardware and software
components. In the context of 5G, SDR plays a crucial role in enabling dynamic and
programmable radio access networks. Some aspects of SD Radio in the context of 5G
include:
 Flexibility and agility: SDR allows the software-defined radio access network to adapt
and reconfigure itself dynamically based on the network requirements and changing
conditions.
 Spectrum efficiency: SDR enables intelligent spectrum management techniques, such as
dynamic spectrum access and cognitive radio, to improve the efficient utilization of
available spectrum resources.
 Network virtualization: SDR can facilitate the virtualization of network functions,
enabling the creation of virtualized radio access networks (vRAN) that are more scalable,
flexible, and cost-effective.
 Multi-RAT support: SDR enables the support of multiple radio access technologies
(RATs) within a single device or network, facilitating seamless connectivity and
interoperability between different wireless technologies.

3. Broadband Communication:
Broadband communication refers to the transmission of high-capacity data over a wide
range of frequencies, enabling fast and reliable communication services. In the context of
wireless communication systems, broadband communication plays a crucial role in
providing high-speed connectivity to users. Some key aspects of broadband
communication in wireless systems include:
 High data rates:
Broadband communication allows for the transmission of large amounts of data at high
speeds, enabling bandwidth-intensive applications such as video streaming, online
gaming, and cloud services.
 Multiple access techniques:
Broadband wireless systems employ multiple access techniques, such as Orthogonal
Frequency Division Multiplexing (OFDM), to maximize the efficient use of available
spectrum resources and support concurrent transmission and reception of data.
 Quality of Service (QoS):
Broadband communication systems prioritize QoS parameters, such as low latency, high
reliability, and high throughput, to meet the requirements of diverse applications and user
demands.
 Mobile broadband:
Broadband communication enables high-speed mobile connectivity, allowing users to
access the internet and other services on the go, thereby enabling mobile broadband
services and applications.
Overall, block chain-based communication, SD Radio for 5G, and broadband communication are
all important topics in the field of wireless communication systems, each bringing unique
benefits and advancements to the wireless industry.

Question No.3: A simulation of a complete digital communication system with different modulation
schemes in MATLAB for transmitting and receiving text messages.
Answer. Code:
clc;
clear all;
close all;
x=[0 1 1 0 0 0 1 0]; % Binary Information
bp=.000001; % bit period
disp('Transmitted bit stream :');
disp(x);
% Binary data in digital form
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=ones(1,100);
else x(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t1=bp/100:bp/100:100*length(x)*(bp/100);
subplot(3,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('message in digital');
% Binary-FSK modulation %
A=5; % Amplitude of carrier signal
rb=1/bp; % bit rate
f1=rb*8; % carrier frequency for information as 1
f2=rb*2; % carrier frequency for information as 0
t2=bp/99:bp/99:bp;
ss=length(t2);
m=[];
for (i=1:1:length(x))
if (x(i)==1)
y=A*cos(2*pi*f1*t2);
else
y=A*cos(2*pi*f2*t2);
end
m=[m y];
end
t3=bp/99:bp/99:bp*length(x);
subplot(3,1,2);
plot(t3,m);
xlabel('time(sec)');
ylabel('amplitude(volt)');
title('Binary FSK modulation signal');
% Binary FSK demodulation
mn=[];
for n=ss:ss:length(m)
t=bp/99:bp/99:bp;
y1=cos(2*pi*f1*t); % carrier siignal for information 1
y2=cos(2*pi*f2*t); % carrier siignal for information 0
mm=y1.*m((n-(ss-1)):n);
mmm=y2.*m((n-(ss-1)):n);
t4=bp/99:bp/99:bp;
z1=trapz(t4,mm) % intregation
z2=trapz(t4,mmm) % intregation
zz1=round(2*z1/bp)
zz2= round(2*z2/bp)
if(zz1>A/2) % logic lavel= (0+A)/2 or (A+0)/2 or 2.5 ( in this case)
a=1;
else(zz2>A/2)
a=0;
end
mn=[mn a];
end
disp(' Demodulated data :');
disp(mn);
%XXXXX Representation of binary information as digital signal which achived
%after demodulation
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
bit=[];
for n=1:length(mn);
if mn(n)==1;
se=ones(1,100);
else mn(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t4=bp/100:bp/100:100*length(mn)*(bp/100);
subplot(3,1,3)
plot(t4,bit,'LineWidth',2.5);grid on;
axis([ 0 bp*length(mn) -.5 1.5]);
ylabel('amplitude(volt)');
xlabel(' time(sec)');
title('Demod data in digital form');

Output:
Transmitted bit stream :
0 1 1 0 0 0 1 0
z1 =

-4.7142e-08

z2 =

2.4499e-06

zz1 =

zz2 =

ans =

logical

z1 =

2.4555e-06

z2 =

-4.7142e-08

zz1 =

zz2 =

z1 =

2.4555e-06

z2 =

-4.7142e-08

zz1 =

5
zz2 =

z1 =

-4.7142e-08

z2 =

2.4499e-06

zz1 =

zz2 =

ans =

logical

z1 =

-4.7142e-08

z2 =

2.4499e-06

zz1 =

zz2 =

ans =

logical

z1 =

-4.7142e-08
z2 =

2.4499e-06

zz1 =

zz2 =

ans =

logical

z1 =

2.4555e-06

z2 =

-4.7142e-08

zz1 =

zz2 =

z1 =

-4.7142e-08

z2 =

2.4499e-06

zz1 =

zz2 =

5
ans =

logical

Demodulated data :
0 1 1 0 0 0 1 0
The File of Matalb is also attached with the Assignment.

You might also like