0% found this document useful (0 votes)
115 views29 pages

Air University: Ali Hamza Objective: The Main Objective of This Lab Is

The document is a lab report summarizing an experiment on representing continuous and discrete time signals in MATLAB. The objectives were to understand digital and continuous signal properties, and generate signals and learn basic MATLAB commands. The lab assessed the student's ability to conduct the experiment and assimilate results. Signals generated included unit impulse, step, ramp, sinusoidal, exponential and random for both continuous and discrete time.

Uploaded by

Mir Adil Latif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views29 pages

Air University: Ali Hamza Objective: The Main Objective of This Lab Is

The document is a lab report summarizing an experiment on representing continuous and discrete time signals in MATLAB. The objectives were to understand digital and continuous signal properties, and generate signals and learn basic MATLAB commands. The lab assessed the student's ability to conduct the experiment and assimilate results. Signals generated included unit impulse, step, ramp, sinusoidal, exponential and random for both continuous and discrete time.

Uploaded by

Mir Adil Latif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

ALI HAMZA LAB REPORT 2 05 APRIL 2021

AIR UNIVERSITY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

EXPERIMENT NO 2

Lab Title: Continuous and Discrete Time Signals Representation in MATLAB

Student Name:Ali Hamza Reg. No: 180464

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

Total Marks: Obtained Marks

LAB REPORT ASSESSMENT:


Excellent Good Average Satisfactory Unsatisfactory
Attributes (5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained Marks:

Date Signature
ALI HAMZA LAB REPORT 2 05 APRIL 2021

Lab 02- Continuous and


Discrete Time Signals Representation in
MATLAB
Objectives:
1. Understand the properties of digital and continuous signals.
2. To learn how to generate continuous signals and Discrete time signals
3. To learn some basic MATLAB commands.

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.

Common basic signals are


▪ Discrete – Time signals:
⎧1, for n = 0
▪ Unit impulse sequence. x(n) = δ (n) = ⎨
⎩ 0, otherwise
⎧1, for n ≥ 0
▪ Unit step sequence. x(n) = u(n) = ⎨
⎩ 0, otherwise
⎧n, for n ≥ 0
▪ Unit ramp sequence.
x(n) = r(n) = ⎨
⎩ 0, otherwise
▪ Sinusoidal sequence. x(n) = Asin( ϖn + φ) .
▪ Exponential sequence. x(n) = A an, where A and a are constant.

▪ Continuous – time signals:


⎧1, for t = 0
▪ Unit impulse signalx. ( t ) = δ ( t ) =

⎩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

2. Procedure for Signal generation:

1. Start the program


2. Get the inputs for signal generation
3. Use the appropriate library function
4. Display the waveform

Source code:

%WAVE FORM GENERATION


%CT SIGNAL
%UNIT IMPULSE
clc;
clear all;
close all;
t1=-3:1:3;
x1=[0,0,0,1,0,0,0];
subplot(2,3,1);
plot(t1,x1);
xlabel('time');
ylabel('Amplitude');
title('Unit impulse signal');
%UNIT STEP SIGNAL
t2=-5:1:25;
x2=[zeros(1,5),ones(1,26)];
subplot(2,3,2);
plot(t2,x2);
xlabel('time');
ylabel('Amplitude');
title('Unit step signal');
%EXPONENTIAL SIGNAL
a=input('Enter the value of a:');
t3=-10:1:20;
x3=exp(-1*a*t3);
subplot(2,3,3);
plot(t3,x3);
xlabel('time');
ylabel('Amplitude');
title('Exponential signal');
%UNIT RAMP SIGNAL
ALI HAMZA LAB REPORT 2 05 APRIL 2021
t4=-10:1:2
ALI HAMZA LAB REPORT 2 05 APRIL 2021

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');

%WAVE FORM GENERATION


%DT SIGNAL
%UNIT IMPULSE
clc;
clear
all;
close
all;
n1=-3:1:3;
ALI HAMZA LAB REPORT 2 05 APRIL 2021
x1=[0,0,0,1,0,0
,0];
subplot(2,3,1);
stem(n1,x1);
xlabel('time');
ylabel('Amplitude');
title('Unit impulse
signal');
%UNIT STEP
SIGNAL n2=-
5:1:25;
x2=[zeros(1,5),ones(1,2
6)]; subplot(2,3,2);
ALI HAMZA LAB REPORT 2 05 APRIL 2021

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:

Output Waveform (Continuous time):


Output Waveform (Discrete Time)
Lab Tasks

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

1. Generate the following signals in MATLAB:


x1[n] = 2 δ(n + 2) - δ(n-4), -5 ≤ n ≤ 5

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----------------------------------------

You might also like