Experiment # 2: Communication Signals: Generation and Interpretation Objective
Experiment # 2: Communication Signals: Generation and Interpretation Objective
Experiment # 2
Objective
To the use of MATLAB for generation of different signals important in communication theory.
Learn the basics of signals and its operations as used in Analogue Communication.
To develop understanding of communication signals and their properties.
Generation of Signals
Signals are represented mathematically as a function of one or more independent variables. We will generally
refer to the independent variable as time. Therefore, we can say a signal is a function of time. Write these
instructions in m-file as execute to see the result.
Sinusoidal Sequence:
% Example 2.1
% Generation of sinusoidal signals
% 2sin( 2πτ-π/2)
t=[-5:0.01:5];
x=2*sin((2*pi*t)-(pi/2));
plot(t,x)
grid on;
axis([-6 6 -3 3])
ylabel ('x(t)')
xlabel ('Time(sec)')
title ('Figure 2.1')
Figure 2.1
SYED FURQAN JAVED (2019-EE-280), SECTION : A
See the output, change the phase shift value and observe the differences.
Figure 2.2
=0 n≠0
We are making a function named imseq and we further use this function in next experiments of this lab. The
MATLAB code is given below:
Function Code:
t = (-1:0.01:5)';
unitstep = t>=0;
plot(t,unitstep)
Plot:
SYED FURQAN JAVED (2019-EE-280), SECTION : A
It is defined as
{
u(n)= 1 n ≥ 0
0 n≤ 0
The MATLAB code for stem sequence function is given below:
Function Code:
Plot:
SYED FURQAN JAVED (2019-EE-280), SECTION : A
We require an array operator “ .^ ” to implement a real exponential sequence. See the MATLAB code below
>> n = [0:10];
>> x = (0.9).^n;
>> n = [0:10];
>> x = (0.9).^n;
It is define as:
Where a is called the attenuation and b is the frequency in radians. It can be implemented by following
MATLAB script.
>> n = [0:10];
Result:
Random Sequence:
SYED FURQAN JAVED (2019-EE-280), SECTION : A
Many practical sequences cannot be described by the mathematical expressions like above, these are called
random sequences. They depend upon the parameters like probability density function or their statistical
moments. In MATLAB two types of random sequences are available. See the code below:
And
>> randn (1,N)
The above instruction generates a length N random sequence whose elements are uniformly distributed
between [0,1]. And the last instruction, randn generates a length N Gaussian random sequence with mean 0
and variance 1. Plot these sequences.
% example 2.3
Figure 2.3
Periodic Sequences:
A sequence is periodic if it repeats itself after equal interval of time. The smallest interval is called the
SYED FURQAN JAVED (2019-EE-280), SECTION : A
fundamental period. Implement code given below and see the periodicity.
% Example 2.4
Figure 2.4
SYED FURQAN JAVED (2019-EE-280), SECTION : A
Signals Operations:
Signal Addition
This is basically sample by sample addition. The definition is given below:
¿
The length of x 1 and x 2 should be equal. See the MATLAB code below:
function [x, n] = sigadd (x1, n1, x2, n2)
% implement y(n) = x1(n) + x2 (n)
% [y, n] = sigadd (x1, n1, x2, n2)
% y = sum sequence over n, which include n1 and n2
% x1 = first sequence over n1
% x2 = second sequence over n2 (n2 can be different from n1)
n = min(min(n1), min(n2)): max(max(n1), max(n2)); %duration of y(n)
y1 = zeros (1, length(n)); % initialization
y2 = y1;
y1(find((n>=min(n1)) &(n<=max(n1)) ==1)) =x1; % x1 with duration of y
y2(find((n>=min(n2)) &(n<=max(n2)) ==1)) =x2; % x2 with duration of y
y = y1 + y2;
end
% Example 2.5
clear;
clc;
n1 = [0:10];
x1 = sin (n1);
n2 = [-5:7];
x2 = 4*sin(n2);
[y,n] = sigadd(x1,n1,x2,n2);
subplot (3,1,1);
stem (n1,x1);
grid on;
axis ([-5 10 -5 5]);
xlabel ('n1');
ylabel ('x1(n)'); title ('1st signal');
subplot (3,1,2);
stem (n2,x2);
grid on; hold on;
axis ([-5 10 -5 5]);
xlabel ('n2');
ylabel ('x2(n)'); title ('2nd
signal');
subplot (3,1,3);
stem (n,y,'r'); grid on;
axis ([-5 10 -5 5]);
xlabel ('n');
ylabel ('y(n)');
title ('Added Signals');
SYED FURQAN JAVED (2019-EE-280), SECTION : A
Figure 2.5
Input & Output on MATLAB:
Signal Multiplication:
The multiplication of two signals is basically sample by sample multiplication or you can say that dot
multiplication. By definition it is
{ x 1 ( n ) } . { x 2 ( n ) }={x 1 ( n ) . x 2(n)}
It is implemented by the array operator “. *” that we studied in last lab. A signal multiplication function is
developed that is similar to the sigadd function. See the code below:
SYED FURQAN JAVED (2019-EE-280), SECTION : A
% Example 2.6
clear;
clc;
n1 = [0:0.1:10];
x1 = sin (n1);
n2 = [-5:0.1:7];
x2 = 4*sin (n2);
[y,n] = sigmult(x1,n1,x2,n2);
subplot (3,1,1);
stem (n1,x1);
grid on;
axis ([-5 10 -5 5]);
xlabel ('n1');
ylabel ('x1(n)');
title ('1st signal');
subplot (3,1,2);
stem (n2,x2);
grid on;
hold on;
axis ([-5 10 -5 5]);
xlabel ('n2');
ylabel ('x2(n)');
title ('2nd signal');
subplot (3,1,3);
stem (n,y,'r');
grid on;
axis ([-5 10 -5 5]);
xlabel ('n');
ylabel ('y(n)');
title 'Multiplied Signals');
SYED FURQAN JAVED (2019-EE-280), SECTION : A
Figure 2.6
POST LAB
You are not allowed to multiply impulse sequences with a number. Implement this by using impseq, stepseq