Sie sind auf Seite 1von 8

Department of Electrical Engineering

Communication Systems

Course Instructor: Dr. Muhammad Mahboob Ur Rahman Dated: 21-09-2016

Lab Instructor: Waseem Abbas Semester: 7th

Lab Instructor: Sanan Ahmad Session: BSEE-13

Group:

LAB-2 Convolution, Correlation, Energy and Power of Signals

Reg. No. Report LAB Viva


Name
Marks Performance Marks Total (15)
(5) (5) (5)

9|Page
Convolution, Correlation, Energy and Power of Signals

2.1 Objective
To learn how we can compute the convolution, correlation, energy and power of the signals

2.2 Equipment/Apparatus
2. Software: Matlab
2.3 Theory and Procedure
Following are the terms mostly used in Communication Systems

2.3.1 Convolution
Convolution describes the relationship between the input signal X[n], the impulse response H[n] of
an LTI system, and the output signal Y[n] (see Figure 2-1).

Linear System
X[n] Y[n]
H[n]

[] [] = []
Figure 0-1 Convolution

In mathematical notation, convolution is described as:

[] = [] []
The Matlab function used for Convolution is conv. C = conv (A, B) convolves vectors A and B and saves the
output in vector C.

Example:
a = [1 0 3 1];
b = [2 3 1 0];
d=conv(a, b)

Result:
d =

2 3 7 11 6 1 0

2.3.2 Correlation
Correlation is a mathematical operation that is very similar to convolution. Just as with convolution,
correlation uses two signals to produce a third signal. It shows how much similar or different are the two
signals when compared with each other. The output signal is called the cross-correlation of the two input
signals. If a signal is correlated with itself, the resulting output signal is instead called the autocorrelation.

Autocorrelation, also known as serial correlation, is the correlation of a signal with itself when second copy
of the signal is delayed compared to the first one. In other words, auto-correlation is the measure of
similarity between the two copies of the same signal as a function of the time lag between them.

10 | P a g e
The Matlab command used for correlation is xcorr.
Example:
Find the autocorrelation and cross-correlation of x and y.
x = [1 0 0 0 0];
y = [0 0 1 0 0];
[xcorr_a n] = xcorr(x, x)
subplot(221)
stem(n, xcorr_a)
xlabel('tau')
ylabel('auto-corelation of x')
[xcorr_a n] = xcorr(y, y)
subplot(222)
stem(n, xcorr_a)
xlabel('tau')
ylabel('auto-corelation of y')
[xcorr_a n] = xcorr(x, y)
subplot(223)
stem(n, xcorr_a)
xlabel('tau')
ylabel('cross-corelation of x and y')

Figure 0-2 correlation

2.3.3 Energy and Power of the Signal


Energy and power of the signal is calculated by the following formulae
=+

= | [] |2
=

11 | P a g e
=+
1
= lim | [] |2
2 + 1
=

Here T = duration of the signal, and x[n] denotes discrete samples of the signal at regular intervals (The
sampled signal contains N points stretching from 0 to N-1). NORM function in Matlab can be utilized for
calculating the power or energy content of a signal.
=1

(, ) = ( |()| )1/
=0
=1

() = (, 2) = ( |()|2 )1/2
=0

Example
%Syntax: (Extracted from Matlab help)
%NORM(V, P) = sum(abs(V).^P)^(1/P).

%sample to calculate Energy and Power

T=10; %Total evaluation time


Ts=0.001; %Sampling time => 1000 samples per second
Fs=1/Ts; % Sampling period
t=[0:Ts:T]; %define simulation time

%sample function to calculate Energy and Power

x=cos(2*pi*100*t) + cos(2*pi*200*t) + sin(2*pi*300*t);


energy = (norm(x)^2);
power = (norm(x)^2)/length(x);
Results:
energy = 1.5004e+04
power = 1.5002
2.3.4 Orthogonality
In mathematics, orthogonality is the relation of two lines at right angles to one another (perpendicularity),
and the generalization of this relation into n dimensions; and to a variety of mathematical relations thought
of as describing non-overlapping, uncorrelated, or independent objects of some kind. In communications,
multiple-access schemes are orthogonal when an ideal receiver can completely reject arbitrarily strong
unwanted signals from the desired signal using different basis functions.

The dot product of orthogonal signals is zero. If we have two orthogonal signals x and y, then following
equation satisfies:

. = 0
2.3.4.1 Orthogonal channel
Consider you are transmitting two signals using same frequency. There will be interference between these
two signals if they are not orthogonal. Orthogonality means both signal is having phase difference of 90
degrees. Hence, it will not interfere each other. Just like CDMA, all the channels are orthogonal and hence
we can use same frequency allocation for all users but signals are decoded based on PN sequence which is
used for spreading the signal. Orthogonal signaling uses carriers which do not correlate with each other
(inner product or mean of mutual multiplication is zero). In case of non-dispersive channel this signaling is

12 | P a g e
very efficient, since there is no interference between carriers. However, most of real-life channels are
dispersive and inter-carrier interference is present. Moreover, orthogonal signaling is much more sensitive
to synchronization errors than non-orthogonal one.

2.3.5 Shannons Formula

The ShannonHartley theorem states the channel capacity C, meaning the theoretical tightest upper bound
on the information rate of data that can be communicated at an arbitrarily low error rate using an average
received signal power S through an analog communication channel subject to additive white Gaussian
noise of power N:

= log2 (1 + )

Where,

C is the channel capacity in bits per second, a theoretical upper bound on the net bit
rate (information rate, sometimes denoted I) excluding error-correction codes;
B is the bandwidth of the channel in hertz (passband bandwidth in case of a bandpass signal);
S is the average received signal power over the bandwidth (in case of a carrier-modulated passband
transmission, often denoted C), measured in watts (or volts squared);
N is the average power of the noise and interference over the bandwidth, measured in watts (or
volts squared); and
S/N is the signal-to-noise ratio (SNR) or the carrier-to-noise ratio (CNR) of the communication signal
to the noise and interference at the receiver (expressed as a linear power ratio, not as
logarithmic decibels).
Example:
Plot capacity of the channel:
i) As a function of SNR (vary SNR between -10 to 30 dB, but then convert it into linear scale)
ii) As a function of BW (vary it between 10KHz to 20 MHz)

B=10^3:10^3:10^6
SNRdb=10
SNR=db2mag(SNRdb)
C = B * log2(1+SNR);
subplot(2,1,1)
plot(B,C);
xlabel('Bandwidth (Hertz)')
ylabel('Channel Capacity (Bits per Second)')
%=================
B=10^3
SNRdb=-10:30
SNR=db2mag(SNRdb)
C = B * log2(1+SNR);
subplot(2,1,2)
plot(SNR,C);
xlabel('SNR')
ylabel('Channel Capacity (Bits per Second)')

13 | P a g e
Figure 0-3 Channel Capacity

2.4 Exercise
Write the codes of following exercises. Print the codes and results with proper labeling. Attach it with the
manual

TASK-1:

One of the most immediate and impressive applications of convolution can be found in the techniques of
digital audio processing. In the past 15 years, a variety of tools using convolution have been developed and
popularized.

The task is to convolution of audio files.

1. Go to the following link and download audios: https://goo.gl/h7wcGZ


2. Import the input wave file x[n].
clapstereo = wavread('/<path>/clap.wav')
[Note: you have to add the Wavefile folder to the path. Select Selected Folders. See figure 2-6]

14 | P a g e
Figure 0-4 Add to Path instructions

3. The audios will be shown in two columns. Each of these columns represents a column
vector in the matrix, corresponding to an audio channel(L/R). This file is a stereo file (it
contains left and right channel information) and so we will need to strip out the left
channel. Type the following
clapmono = clapstereo(:,1)
4. Next, do the same procedure with the impulse response H(n) file
hallstereo = wavread('<path>/LongEchoHallIR.wav')
hallmono = hallstereo(:,1)
5. Now convolute the X[n] and H[n]
out1 = conv(clapmono, hallmono)
6. Before we can write this to a new file, we must normalize this vector so that none of its
entries is bigger than 1 in absolute value. This is because .wav files require the amplitude
of all waveforms to be between -1 and 1. (Note: Waveforms which 'clip'(exceed the
maximum level) are not useful, as they play back with ugly digital distortion. This is to be
avoided, always, when working with digital audio). To normalize the vector, we write:
% max(v) = absolute value of largest entry of v
out1normalized = out1/max(out1)
7. We now have a vector which is suitable to be exported! Let's write this to a file:
%The second parameter is the sample rate
wavwrite(out1normalized, 44100, '<path>/out1.wav')
8. Use Hands-free (ear-in or earbuds) to listen to the audio
9. Now do the same for clap and drumloop sound or some other combinations of your
liking.
TASK-2:

Find auto-correlation and cross-correlation of PN_seq and show results in the form of graph (Like the
Example given in correlation i.e. section 2.3.2).
PN_seq_1 = randn(10,1)

15 | P a g e
PN_seq_2 = randn(10,1)
TASK-3:

Execute the following code and explain the difference between convolution and correlation.
x = [1 2 3 4];
y = [-1 2 1 -1];
conv(x,y)
conv(fliplr(x),y)
xcorr(x,y)

TASK-3:

Find whether or not Sin(x) and Cos(x) are orthogonal or not for period of 0 t 2. And also find
orthogonality of Sin(x) with Sin(2x) and Sin(3x) for period of 0 t 2. Show results in the form of graphs.

[Hint: Specify the argument x in radians, not in degrees. For example, use to specify an angle of 180 o. Use
dot (a, b) or sum(x.*y)]

TASK-4:

Compute the effect of doubling the bandwidth BW and doubling the SNR on channel capacity (using
Shannons formula) and see which parameter (among BW and SNR) has dominating effect. SNR: -10 dB,
Bandwidth: 20KHz

TASK-5:

Calculate RMS value of signal: Sin(2x) from 0 to 2.

2.5 Student Learning Outcomes


What you have learnt in the lab? Describe.

16 | P a g e

Das könnte Ihnen auch gefallen