Air University: Ali Hamza Objective: The Main Objective of This Lab Is
Air University: Ali Hamza Objective: The Main Objective of This Lab Is
AIR UNIVERSITY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING
EXPERIMENT NO 2
Objective: The Main objective of this lab is Understand the properties of digital and continuous signals
as well as To learn how to generate continuous signals and Discrete time signals and To learn some
basic MATLAB commands.
LAB ASSESSMENT:
Excellent (5) Good Average Satisfactory Unsatisfactory
Attributes (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and follows
the lab safety rules
Data presentation
Experimental results
Conclusion
Date Signature
ALI HAMZA LAB REPORT 2 05 APRIL 2021
Introduction:
Signals: All the signals have to be either vectors (row or column), or matrices in MATLAB of
finite length. The index of the vector usually corresponds to time, and it always has to be 1 to
N, if N is assumed to be the length of the vector. MATLAB has the power to perform vector
operations quite efficiently, implying that processing of signals is easy.
As a general rule, discrete signals are viewed using ‘stem’ and indices must be plotted on the
axis. It’s always a good habit to label all the axes and title the figures properly.
⎩0, otherwise
⎧1, for t ≥ 0
x (t ) = u( t ) = ⎨
▪ Unit step signal.
⎩0, otherwise
⎧t , for t ≥ 0
x(t)=r(t)=
⎨
▪ Unit ramp signal. ⎩0, otherwise
▪ Sinusoidal signal.
x(t ) =
ALI HAMZA LAB REPORT 2 05 APRIL 2021
A sin((ϖt+ φ) .
x ( t ) = A e at
▪ Exponential signal. , where A and a are constant.
ALI HAMZA LAB REPORT 2 05 APRIL 2021
Source code:
x4=t4;
subplot(2,3
,4);
plot(t4,x4);
xlabel('time');
ylabel('Amplitude');
title('Unit ramp
signal');
%SINUSOIDAL SIGNAL
A=input('Enter the
amplitude:'); f=input('Enter
the frequency:'); t5=-
10:1:20;
x5=A*sin(2*pi*f*t5)
; subplot(2,3,5);
plot(t5,x5)
xlabel('time');
ylabel('Amplitude');
title('Sinusoidal
signal');
%RANDOM
SIGNAL t6=-
10:1:20;
x6=rand(1,
31);
subplot(2,3,
6);
plot(t6,x6);
xlabel('time');
ylabel('Amplitude');
title('Random signal');
stem(n2,x2);
xlabel('time');
ylabel('Amplitude');
title('Unit step signal');
%EXPONENTIAL SIGNAL
a=input('Enter the value of a:');
n3=-10:1:20;
x3=power(a,n3);
subplot(2,3,3);
stem(n3,x3);
xlabel('time');
ylabel('Amplitude');
title('Exponential signal');
%UNIT RAMP SIGNAL
n4=-10:1:20;
x4=n4;
subplot(2,3,4);
stem(n4,x4);
xlabel('time');
ylabel('Amplitude');
title('Unit ramp signal');
%SINUSOIDAL SIGNAL
A=input('Enter the amplitude:');
f=input('Enter the frequency:');
n5=-10:1:20;
x5=A*sin(2*pi*f*n5);
subplot(2,3,5);
stem(n5,x5);
xlabel('time');
ylabel('Amplitude');
title('Sinusoidal signal');
%RANDOM SIGNAL
n6=-10:1:20;
x6=rand(1,31);
subplot(2,3,6);
stem(n6,x6);
xlabel('time');
ylabel('Amplitude');
title('Random signal');
ALI HAMZA LAB REPORT 2 05 APRIL 2021
3. Results
Continuous time:
Discrete time:
Creation of Signals
We will often need the functions for these general signals:
• a unit impulse: δ(n-n0) of desired length
• a unit step: u(n-n0) of desired length
• shifter: a function which gives the input signal an arbitrary shift of n0
SOURCE CODE:
OUTPUT
x2[n] = n(u[n] – u[n-10]) + 10 exp(-0.3(n-10)) (u[n-10]-u[n-20]) 0 ≤ n ≤ 20
INPUT
OUTPUT
x3[n] = cos(0.04πn) + 0.02w[n], for 0 ≤ n ≤ 50, where w[n] is a gaussian random signal
INPUT
OUTPUT
x4[n] is signal of four periods of sequence [5,4,3,2,1], in the range -10 ≤ n ≤ 9
INPUT
OUTPUT
2. Sinusoids--- the most general category of signals. Yes, it’s true. Believe it or not, every
signal in this universe contains nothing but sinusoids. We’ll explore this aspect in detail in
our later labs, but for now, these signals are quite interesting and beautiful to be looked in
detail.
x1[n] = sin ( 17 π n)
0 ≤ n ≤ 25
INPUT
OUTPUT
x2[n] = cos (17πn), -15 ≤ n ≤ 15
INPUT
OUTPUT
x3[n] = sin (3 π n), -10 ≤ n ≤ 10
INPUT
OUTPUT
x4[n] = cos (23πn), 0 ≤ n ≤ 50
INPUT
OUTPUT
3. Complex Exponentials: Generate x0[n] = exp (j*n/3), for some range
and see its real and imaginary parts separately. Also make the
following signals:
INPUT
OUTPUT
INPUT
OUTPUT
INPUT
OUTPUT
• x1[n] = e(-0.1+j0.3)n, -10 ≤ n ≤ 10
INPUT
OUTPUT
OUTPUT
OUTPUT
• x2[n] = an u[n], where a=0.9, and 1.1 for -50 ≤ n ≤ 100
OUTPUT
OUTPUT
INPUT
OUTPUT
• x3[n] = 3 sin (17πn) + j 4 cos (17πn), 0 ≤ n ≤ 25
OUTPUT
CONCLUSION:
In this lab we have implemented different operations on different functions.
1. Firstly we have applied matlab commands for delta functions and obtain different results in the
form of graphs.
2. We have used different matlab commands like:
a) Axis (that decides the limits of x-axis as well as y-axis.)
b) Plot (that plots signals in the form of continuous signals).
c) Subplot (that describes the no of rows,columns and position)
d) Stem(that plots signals in the form of discrete signals)
3. we have also analyze the behaviour of functions like:
a) impulse function.
b) Unit step function.
c) Exponential function.
d) Complex exponential functions.
4. We have also analyzed the behaviour of real and imaginary parts of complex exponential signals.
-------------------------------------------------THE END----------------------------------------