Vous êtes sur la page 1sur 3

Digital Signal Processing 2019

LAB 02
“Generating Discrete Time Signal, Performing Various Operations and
Convolution of discrete time signals”

Previous Lab:

In pervious labs students were introduced to matlab environment in depth, the process of help
about any function was explained in details, how to use apps, how to use plots, how to use similink,
how to publish a document, how to work in script file how to use comment in code for creating
sections.

Objective:

1. Generating basic discrete time signals


2. Performing manipulations on these signals like shifting/scaling, addition/subtraction etc
3. Performing discrete time convolution
4. Processing discrete time signals through systems like expander/compressor

Useful Matlab function/commands:


Stem Plot Figure Subplot Title Grid
Xlabel Ylabel For If Zeros Ones
Exp Sign Eps Clc Close all Clear all
Function Min Max Sinc Find mod

Help on these commands is available in Matlab help directory.


Procedure:
1. Open M-file or M-Book. (There should be only one m-file for this whole assignment)
2. Save it by any useful name but remember not to start the name by any numeric digit, do not
use any special character other than under-the score (_) and also remember not to give any
space in the name.
3. Write an appropriate MATLAB code for generating the basic sequences then perform basic
sequence operations.
4. Always write clc; clear all; close all; at the beginning of m file and use “%” for commenting.
5. Show all your results in MATLAB figure using “figure” and “subplot” command.

Instruction :- Do comment infront of every statement you type in matlab m file.

Prepared by Dr. Muhammad Bilal Qureshi ECE Dept CUI, ATD Page 1
Digital Signal Processing 2019

1. Compute the following expressions:

𝟑 𝜋 𝟕
𝑨 = 𝟏𝟐 + 𝒆𝒋 𝟐 + 𝟒 ∗
𝟐 𝟑 ∗ 𝟒√𝟒
𝜋 9
𝑩 = 𝒔𝒊𝒏 + 7 + ∗ 17
2 2
2. Write the MATLAB code for plotting the following basic sequences.
Note (There should be only one plot for each part, use subplot command if there are
multiple plots in a single part).

a) 𝒙[𝒏] = 𝜹[𝒏]

b) 𝒙[𝒏] = 𝒖[𝒏]

−𝟏 𝟐
c) 𝒙𝟏 [𝒏] = [ 𝟐 , 𝟏, 𝟒 , 𝟎, 𝟏, −𝟑, −𝟐], 𝒙𝟐 [𝒏] = [𝟎, 𝟏, 𝟒, 𝟑, −𝟏, −𝟐, −𝟑]

𝟑 𝝅
d) 𝒙𝟏 [𝒏] = 𝟐 𝐜𝐨𝐬 (𝝎𝒏 + 𝟐 ), 𝒇 = 𝟎. 𝟐𝟔𝒉𝒛, −𝟐𝟎 ≤ 𝒏 ≤ 𝟐𝟎
𝒙𝟐 [𝒏] = 𝟐 𝐜𝐨𝐬(𝝎𝒏 + 𝝅), 𝒇 = 𝟎. 𝟏𝟒𝒉𝒛, −𝟐𝟎 ≤ 𝒏 ≤ 𝟐𝟎

e) 𝒙𝟏 [𝒏] = (𝟎. 𝟑)𝒏 −𝟏𝟎 ≤ 𝒏 ≤ 𝟏𝟎


𝒙𝟐 [𝒏] = (𝟑)𝒏 −𝟏𝟎 ≤ 𝒏 ≤ 𝟏𝟎
𝒙𝟑 [𝒏] = (𝟎. 𝟖𝟒)𝒏 𝒖[𝒏] −𝟏𝟎 ≤ 𝒏 ≤ 𝟏𝟎
𝒙𝟒 [𝒏] = −𝟐(𝟎. 𝟖𝟓𝒋)𝒏 −𝟏𝟎 ≤ 𝒏 ≤ 𝟏𝟎

f) Using 𝒙𝟏 [𝒏] and 𝒙𝟐 [𝒏] of part (c) perform the following:


a. 𝒙𝟏 [𝒏]+𝒙𝟐 [𝒏]
b. −𝟒𝒙𝟏 [𝒏 + 𝟏]+𝟑𝒙𝟐 [𝒏 − 𝟔]

3. Check the syntax of writing functions in matlab’s help, then write the below mentioned
expression in matlab function to generate unit step sequence.

𝒔𝒊𝒈𝒏(𝒏 + 𝒆𝒑𝒔) + 𝟏
𝑢[𝑛] =
𝟐

4. Generate the following sequences using the command of ones and zeros without using
multiple statements.

Prepared by Dr. Muhammad Bilal Qureshi ECE Dept CUI, ATD Page 2
Digital Signal Processing 2019

𝟏 − 𝟐𝟎 ≤ 𝒏 ≤ −𝟏𝟎
−𝟏𝟐 − 𝟗 ≤ 𝒏 ≤ −𝟔
𝒙[𝒏] = 𝟑 − 𝟓 ≤ 𝒏 ≤ −𝟐
𝟏𝟎 𝒏 = −𝟏
{−𝟕. 𝟓 𝟎 ≤ 𝒏 ≤ 𝟐𝟎}

5. Plot the impulse response of following systems.

i) Ideal Delay
ii) Moving Average for any range
iii) Forward difference
iv) Backward difference

6. Write a matlab code to compute the sum of 𝒉[𝒏] = 𝟒𝒏 (𝒖[𝒏] − 𝒖[𝟏𝟎𝟎]) without using the
geometric series formula first and then verify the result with the help of formula.

7. Write a MATLAB code for plotting output y[n] of an LTI system for the following input and
impulse response: using convn with ‘same’ length and then repeat all for ‘full’ length
parameter. (Check the help of convn to see the difference between same and full length
convolution).
i) 𝒙[𝒏] = 𝒖[𝒏] 𝒉[𝒏] = 𝒂𝒏 𝒖[𝒏] − 𝟏𝟓 ≤ 𝒏 ≤ 𝟏𝟓 𝒘𝒉𝒆𝒓𝒆 𝒂 = 𝟎. 𝟕
𝒏
ii) 𝒙[𝒏] = −𝟎. 𝟕𝟓𝒖[𝒏] 𝒉[𝒏] = 𝒂 𝒖[−𝒏 − 𝟐] − 𝟏𝟓 ≤ 𝒏 ≤ 𝟏𝟓 𝒘𝒉𝒆𝒓𝒆 𝒂 = 𝟎. 𝟏𝟓
𝒏
iii) 𝒙[𝒏] = 𝟑𝒖[𝒏] − 𝟑𝒖[𝒏 − 𝟒] − 𝟏𝟎 ≤ 𝒏 ≤ 𝟏𝟎 𝒉[𝒏] = 𝟑 𝒖[𝒏] − 𝟒 < 𝒏 < 𝟒

For the generation of unit steps for above sequences use the generic function of unit step.

Each figure should contain the input sequence plot x[n], the impulse response plot h[n], same
length convolution plot y[n] and full length convolution plot y[n] respectively.

8. Write the generic matlab codes for the expansion and compression of following sequences.
i) 𝒙𝟏 [𝒏] = {−𝟐. 𝟓 𝟐 𝟏 𝟕 𝟑 𝟎. 𝟓 − 𝟓} Expand it with M=2 and Compress it with L=2

 First plot the input sequence then plot the expanded version and after that the compressed
version and repeat the same for ii) part.

9. Plot and analyze a sinc function in matlab.

Prepared by Dr. Muhammad Bilal Qureshi ECE Dept CUI, ATD Page 3

Vous aimerez peut-être aussi