0% found this document useful (0 votes)
18 views14 pages

DSP Lab Report 1

The document outlines Lab #1 for the EEE-324 Digital Signal Processing course, focusing on discrete-time signal processing using MATLAB. It includes tasks such as generating and plotting continuous and discrete signals, calculating running averages, and computing variance and mean of a signal. The lab emphasizes hands-on experience with MATLAB to understand key signal processing concepts and their applications.

Uploaded by

Obaid
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)
18 views14 pages

DSP Lab Report 1

The document outlines Lab #1 for the EEE-324 Digital Signal Processing course, focusing on discrete-time signal processing using MATLAB. It includes tasks such as generating and plotting continuous and discrete signals, calculating running averages, and computing variance and mean of a signal. The lab emphasizes hands-on experience with MATLAB to understand key signal processing concepts and their applications.

Uploaded by

Obaid
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/ 14

EEE-324 Digital Signal Processing

Lab # 1
NAME M.OBAID TAHIR

REGISTRATION NUMBER FA22-BEE-193

CLASS/SECTION BEE-6A

INSTRUCTOR DR.BAKHTAIR ALI


Introduction to Discrete Time Signal Processing on MATLAB
Objective:
This introductory lab allows students to understand the basic concept of the discrete-time signals
and their representation on MATLAB. Furthermore, it demonstrates some basic MATLAB codes
in order to achieve hands-on it.

Lab Task 1:
Generate a Continuous time cosine signal and plot it.
MATLAB CODE:

OUTPUT:
EXPLANATION:
In this task we generate a continuous-time cosine signal through MATLAB. We define the time
vector t between 0 and 7 with a step size for the smooth plot. The cosine signal y1 is calculated
as cos(t).In output we receive the continuous-time cosine signal within the given time interval.
This graph illustrates the periodicity of the cosine function, whose amplitude varies between -1
and 1 over time, showing basic principles in continuous-time signal processing.

Lab Task 2:
Generate a Discrete time exponential signal and plot it.
MATLAB CODE:

OUTPUT:
EXPLANATION:
In this task we generate a discrete-time exponential signal with MATLAB. We create a time
vector n from 0 to 9 and specify the exponential base as 0.7. The signal x is calculated as (0.7^n)
for each time n. In output we obtain a graph illustrating the exponential decay of the signal with
time, this output graphically illustrates how the amplitude of the signal decays exponentially with
time, showing the exponential decay nature of discrete-time systems.

Lab Task 3:
Write a MATLAB program for the ‗running average‟, a running total is a sequence of
partial sum of a given sequence/signal. For example, the running totals of the signal {a, b, c,
…}are a, a+b, a+b+c, ... Use that program to find the running total of the discrete time
signal of length N=100. Write your program so that it is flexible. That is, you should be able
to invoke your program from the command window as follows:
>> y=running_averagel(x)
where x is the input signal, and y is the running total of that signal.

MATLAB CODE:

COMMAND WINDOW:
EXPLANATION:
In this task, we create a program to find the running average of a discrete-time signal. The
program computes the cumulative sum of the signal and divides by the number of elements up to
each point in order to get the running average. When the program is called in the command
window as y = running_average(x), it displays the running average values for each point in the
signal, showing how the average changes as more data points are included.

Lab Task 4:
Write a program to compute the variance and mean of a signal x. The variance is defined
to be:

Where x denotes the mean of the signal x. For signal x, use all the integers from 1 to 1000.
MATLAB CODE:

COMMAND WINDOW:

EXPLANATION:
In this task, we write a program to compute the mean and variance of a signal ( x ) consisting of
integers from 1 to 1000. The mean is calculated as the average of all elements in the signal, while
the variance measures the spread of the signal values around the mean. The program calculates
these values and displays them in the command window.
Lab Task 5:
Can you explain what the following program does:

MATLAB CODE:

COMMAND WINDOW:

EXPLANATION:
As we can see from the output on the command window, for values less than 0, the program
replaces them with -1, while for values greater than or equal to 0, the original numbers remain
unchanged. The program ensures that all negative values in x are replaced with -1, while zero
and positive values retain their original sequence.
Lab Task 6:
Generate a step sequence u [n] as described in In-Lab section, use it to generate an impulse
as δ [n] = u[n] 3 u[n-1].

MATLAB CODE:
OUTPUT:

EXPLANATION:
In this task, we generate and plot discrete-time unit step and unit impulse sequences using
MATLAB. The unit step sequence u[n] is created to be 1 for (n >0) and 0 otherwise. The shifted
unit step sequence u [n-1] is also generated. Using these, the unit impulse sequence (delta[n] ) is
computed as ( delta[n] = u[n] - u[n-1] ).In output we get three graphs :
Unit Step Sequence ( u[n] )This graph shows a signal that is 0 for all ( n < 0 ) and 1 for all ( n
>0), representing a sudden change in amplitude at ( n = 0 ).
Shifted Unit Step Sequence ( u[n-1] ):This graph shows a signal that is 0 for all ( n < 1 ) and 1
for all ( n>1 ), representing the same sudden change but shifted by one unit in time.
Unit Impulse Sequence (delta[n] ): This graph shows a signal that is 1 at ( n = 0 ) and 0
elsewhere, representing a single pulse at the origin, which is a fundamental concept in signal
processing.
Lab Task 7:
Generate an impulse sequence δ [n] as described in In-Lab section, use it to generate step
sequence.
MATLAB CODE:
OUTPUT:

EXPLANATION:
In this task, we generate and plot discrete-time impulse and step sequences using MATLAB. The
impulse sequence (delta[n]) is created to be 1 at (n = 0) and 0 elsewhere. Using this impulse
sequence, the step sequence (u[n]) is generated by cumulatively summing the impulse sequence.
In output we get two graphs:
Discrete-Time Impulse Sequence (delta[n]): This graph shows a single spike at (n = 0),
representing an impulse, which is a fundamental signal in signal processing.
Discrete-Time Step Sequence (u[n]):* This graph shows a signal that transitions from 0 to 1 at (n
= 0) and remains at 1 for all (n >0), representing a unit step.

Lab Task 8:
Generate the following sequences using step and impulse sequence:
A. MATLAB CODE:

OUTPUT:
B. MATLAB CODE:

OUTPUT:

C. MATLAB CODE:
OUTPUT:

EXPLANATION:
In Part A, We get a graph shows a rectangular pulse that starts at ( n = 0 ) and ends at ( n = 10 ).
The signal is generated by subtracting a delayed unit step sequence ( u[n-10] ) from the unit step
sequence ( u[n] ). This results in a signal that is 1 for (0 < n < 10 ) and 0 elsewhere.
In Part B, The code likely generates an exponential signal of the form ( x[n] = a^n ), where ( a )
is a constant that determines whether the signal decays or grows. If ( |a| < 1 ), the signal decays,
and if ( |a| > 1 ), the signal grows.
In Part C, The code involves the summation likely combines multiple scaled or shifted versions
of the impulse or exponential signals. The output shows a graph of the combined signal, which
includes the effects of the exponential, impulse, and summation. The output plot likely shows a
signal with pulses at specific points, representing the effect of the impulse function δ(n−1)

CRITICAL ANALYSIS:
In this lab, we learned about some concepts related discrete time signals on MATLAB. We
generated and analyzed signals such as exponential sequences, unit step and impulse sequences,
running averages, and cosine signals. Each task involved creating specific signals, plotting them,
and interpreting their behavior. These exercises helped us understand key signal processing
concepts, including signal generation, shifting, and transformation. By visualizing these signals,
we gained insights into their properties and applications in analyzing and designing discrete-time
systems. Overall, these tasks provided a practical foundation for working with signals in
MATLAB and understanding their role in signal processing.

You might also like