Professional Documents
Culture Documents
Dspli 1 (Part I)
Dspli 1 (Part I)
Experiment No.1-Part(I)
Digital Signal Processing Laboratory I
Iraq, Baghdad
coe.19.003@student.uotechnology.edu.iq
Digital Signal Processing Laboratory I 2023-2022 EXP.NO.1-PART(I): Generation Discrete Signals
➢ Aim
To generate basic signals like unit impulse, unit step, unit ramp, exponential and sinusoidal
signals using MATLAB.
➢ Theory
Whether analog or digital, information is represented by the fundamental quantity in
electrical engineering the signal. Stated in mathematical terms, a signal is merely a function.
Analog signals are continuous-valued, digital signals are discrete-valued. The independent
variable of the signal could be time (speech, for example) space (images).
• Continuous-Time Signal: data are available or measured every time (or space) instant the
data are defined over a continuous input.
• Discrete-Time Signal: defined only for discrete points in time such as every minute, hour,
3 months, year, etc. You sample or collect data at these times only.
• Basic signals:
1. Unit samples sequence.
1, 𝑛 = 𝑛𝑜
𝛿[𝑛 − 𝑛𝑜 ] = {
0, 𝑛 ≠ 𝑛𝑜
3. Exponential Sequence.
𝑥[𝑛] = 𝑎𝑛 , ∀𝑛; 𝑎 ∈ 𝑅
5. Sinusoidal sequence.
𝑥[𝑛] = sin(𝜔𝑛)
Digital Signal Processing Laboratory I 2023-2022 EXP.NO.1-PART(I): Generation Discrete Signals
➢ Procedure
Write the following MATLAB code in the PC.
1. Discrete time signal.
1 1 5
Ramp sequence
0.8 0.8 4
Unit impluse sequence Unit step sequence
Amplitude(V)
Amplitude(V)
Amplitude(V)
0.6 0.6 3
0.4 0.4 2
0.2 0.2 1
0 0 0
-5 0 5 -5 0 5 0 1 2 3 4 5
Sample(n) Sample(n) Sample(n)
-15
x 10
1 5
0.8
0
Exponential sequence
Amplitude(V)
Amplitude(V)
0.6
-5
0.4
Sinusoidal sequence
-10
0.2
0 -15
0 5 10 15 20 0 2 4 6 8 10 12 14 16 18 20
Sample(n) Sample(n)
2. To generate continuous time signal repeat previous program and use plot function
instead of stem function.
close all;
clear all;
clc;
1 1 5
0.8 0.8 4
Unit impluse signal Unit step signal Ramp signal
Amplitude(V)
Amplitude(V)
Amplitude(V)
0.6 0.6 3
0.4 0.4 2
0.2 0.2 1
0 0 0
-5 0 5 -5 0 5 0 1 2 3 4 5
Time(S) Time(S) Time(S)
1 1
0.8
0.5
Exponential signal
Amplitude(V)
Amplitude(V)
0.6
0
0.4
-0.5
0.2
Sinusoidal signal
0 -1
0 5 10 15 20 0 2 4 6 8 10 12 14 16 18 20
Time(S) Time(S)
➢ Discussion
1. Modify program to generate:
1.1 A delayed unit sample sequence with a delay of (15) samples.
Digital Signal Processing Laboratory I 2023-2022 EXP.NO.1-PART(I): Generation Discrete Signals
n=-1:1:16; x=((n-15)==0);
stem(n,x,'r'); legend('Unit impluse sequence');
xlabel('Samples(n)'); ylabel('Amplitude(V)');
grid;
ylim([-0.5 1.5]); %to control the upper and lower of y-axis
limits on a graph
1.5
1
Amplitude(V)
0.5
-0.5
-2 0 2 4 6 8 10 12 14 16
Samples(n)
n=-16:1:2; x=((n+15)>=0);
stem(n,x); legend('Unit step sequence');
xlabel('Samples(n)'); ylabel('Amplitude(V)');
ylim([-0.5 1.5]); grid;
Digital Signal Processing Laboratory I 2023-2022 EXP.NO.1-PART(I): Generation Discrete Signals
1.5
Unit step sequence
1
Amplitude(V)
0.5
-0.5
-16 -14 -12 -10 -8 -6 -4 -2 0 2
Samples(n)
n=0:1:20; x=exp(1.2*n);
stem(n,x,'r'); legend('Exponential sequence');
xlabel('Sample(n)'); ylabel('Amplitude(V)');
grid; axis([-1 21 -0.5e10 3.5e10]);
10
x 10
3.5
Exponential sequence
2.5
2
Amplitude(V)
1.5
0.5
-0.5
0 2 4 6 8 10 12 14 16 18 20
Sample(n)
Digital Signal Processing Laboratory I 2023-2022 EXP.NO.1-PART(I): Generation Discrete Signals
2 2
1 1
Amplitude(V)
Amplitude(V)
0 0
-1 -1
Sinusoidal sequence with 0.8 Sinusoidal sequence with 1.5
-2 -2
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
Sample(n) Sample(n)
1
Amplitude(V)
-1
Sinusoidal sequence with 4
-2
0 1 2 3 4 5 6 7
Sample(n)
Digital Signal Processing Laboratory I 2023-2022 EXP.NO.1-PART(I): Generation Discrete Signals
n=-1:1:4; x=(2*(n==0))+(3*((n-1)==0))-(5*((n-3)==0));
stem(n,x,'r'); legend('x[n] sequence');
xlabel('Sample(n)'); ylabel('Amplitude(V)');
ylim([-6 4]); grid;
4
x[n] sequence
3
0
Amplitude(V)
-1
-2
-3
-4
-5
-6
-1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5 4
Sample(n)
3. Generate and display a random signal of length 100 with elements uniformly distributed
in interval [-2,2] is given below along with the plot of the random sequence generated.
1
Amplitude(V)
-1
-2
-3
0 10 20 30 40 50 60 70 80 90 100
Sample(n)
6
r[n-5] sequence
4
Amplitude(V)
-1
-2 0 2 4 6 8 10
Sample(n)
Digital Signal Processing Laboratory I 2023-2022 EXP.NO.1-PART(I): Generation Discrete Signals
n=-5:1:20; x=(0.8.^n).*(n>=0);
stem(n,x); legend('r[n-5] sequence');
xlabel('Sample(n)'); ylabel('Amplitude(V)');
ylim([-0.5 1.5]); grid;
1.5
r[n-5] sequence
1
Amplitude(V)
0.5
-0.5
-5 0 5 10 15 20
Sample(n)
Graph
▪ Plot: It's an instruction used in the MATLAB to represent and plot the continuous-
time signal. The syntax as (t,x), where “x” is refer to dependent variable and “t” is
refer to independent variable.