Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views4 pages

Lab 4

The document outlines Experiment 03 from the Digital Signal Processing Laboratory at American International University Bangladesh, focusing on discrete-time signals and systems using MATLAB. It details various operations on signal sequences, including addition, multiplication, scaling, time shifting, folding, sample summation, and energy and power calculations. The experiment also includes practical problems for generating and analyzing specific signal sequences.

Uploaded by

miraz09191
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)
10 views4 pages

Lab 4

The document outlines Experiment 03 from the Digital Signal Processing Laboratory at American International University Bangladesh, focusing on discrete-time signals and systems using MATLAB. It details various operations on signal sequences, including addition, multiplication, scaling, time shifting, folding, sample summation, and energy and power calculations. The experiment also includes practical problems for generating and analyzing specific signal sequences.

Uploaded by

miraz09191
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/ 4

American International University Bangladesh

Faculty of Engineering
Digital Signal Processing Laboratory

Experiment no. 03
Experiment Name: - Discrete-Time Signals and Systems - Part II

Objective:

1. Study and observation of basic signal generation using Matlab.

Introduction:

In our last Laboratory experiment we learnt how to define some signal sequences, like impulse
sequences, unit step sequences, etc. In this experiment we will focus on how to do some simple
operations on signal, like addition, multiplication, etc.

Operations on Sequences:

1. Signal addition:

This operation is simply, a sample-by-sample addition and is given by

{x1 (n)} + {x2 (n)} = {x1 (n) + x2 (n)}

It is implemented in MATLAB by the arithmetic operator “+”. However, the important thing
to note is that, lengths of the two sequences must be the same. Now we will create a new
function of our own, sigadd(), which will add two signal sequences of arbitrary duration. The
steps are as follows.

function [y,n] = sigadd(x1,n1,x2,n2)


% implements y(n) = x1(n)+x2(n)
% -----------------------------
% [y,n] = sigadd(x1,n1,x2,n2)
% y = sum sequence over n, which includes n1 and n2
% x1 = first sequence over n1
% x2 = second sequence over n2 (n2 can be different from n1)
%
n = min(min(n1), min(n2)) : max(max(n1), max(n2)); % duration
% of y(n)
y1 = zeros(1, length(n)); y2 = y1; % initialization
y1(find((n>=min(n1)) & (n<=max(n1))==1)) = x1; % x1 with
% duration of y
y2(find((n>=min(n2)) & (n<=max(n2))==1)) = x2; % x2 with
% duration of y
y = y1 + y2;

2. Signal multiplication:

Page 1 of 4
When we need to multiply two signal sequences, we need sample-by-sample multiplication (or
“dot” multiplication) given by

{x1 (n)}.{x2 (n)} = {x1 (n) x2 (n)}

It is implemented in MATLAB by the array operator “.*”. Once again, the similar restrictions
apply for the .* operator as the + operator. Therefore, we can use the following sigmult()
function, designed by us and only to serve our purpose.

function [y,n] = sigmult(x1,n1,x2,n2)


% implements y(n) = x1(n)*x2(n)
% -----------------------------
% [y,n] = sigmult(x1,n1,x2,n2)
% y = product sequence over n, which includes n1 and n2
% x1 = first sequence over n1
% x2 = second sequence over n2 (n2 can be different from n1)
%
n = min(min(n1), min(n2)) : max(max(n1), max(n2)); % duration
% of y(n)
y1 = zeros(1, length(n)); y2 = y1; % initialization
y1(find((n>=min(n1)) & (n<=max(n1))==1)) = x1; % x1 with
% duration of y
y2(find((n>=min(n2)) & (n<=max(n2))==1)) = x2; % x2 with
% duration of y
y = y1 .* y2;
3. Scaling or multiplication of a sequence with a scaler:
In this operation each sample is multiplied by a scalar α .
α { x ( n)} = {α x ( n)}
An arithmetic operator “*” is used to implement the scaling operation in MATLAB.
4. Time Shifting of sequences:
In this operation each sample of x(n) is shifted by an amount ‘k’ to obtain a shifted sequence
y(n).
y ( n) = {x (n − k )}
If we let m = n-k, then n = m+k and the above operation is given by
y ( m + k ) = {x ( m)}
Hence this operation has no effect on the vector x, but the vector n is changed by adding k to
each element. Now we will define a function named sigshift() to do this shifting operation.

function [y, n] = sigshift(x,m,n0)


% implements y(n) = x(n-n0)
% -------------------------------
% [y, n] = sigshift(x,m,n0)
%
n = m+n0; y = x;

Page 2 of 4
5. Folding of sequences:

In this operation each sample of x(n) is flipped around n = 0 to obtain a folded sequence y(n).

y ( n) = {x ( − n)}
In MATLAB this operation is implemented by fliplr(x) function for sample values and
by -fliplr(n) function for sample positions as shown in the sigfold function of our
design.

function [y, n] = sigfold(x,n)


% implements y(n) = x(-n)
% -------------------------------
% [y, n] = sigfold(x,n)
%
y = fliplr(x); n = -fliplr(n);

6. Sample summation:

This operation differs from signal addition operation. It adds all sample values of x(n) between
n1 and n2.
n2

∑ x(n) = x(n ) + ... + x(n )


n = n1
1 2

It is implemented by the sum(x(n1:n2)) a built in Matlab function.

7. Sample products:

This operation also differs from signal multiplication operation. It multiplies all sample values
of x(n) between n1 and n2.
n2

∏ x(n) =x(n ) × ... × x(n )


n = n1
1 2

It is implemented by the prod(x(n1:n2))a built in Matlab function.

8. Signal energy:

The energy of a sequence x(n) is given by

∞ ∞
ε x = ∑ x ( n) x* ( n) = ∑ x ( n)
2

−∞ −∞
where superscript * denotes the operation of complex conjugate. The energy of a finite-
duration sequence x(n) can be computed in MATLAB using the following approaches:

>> Ex = sum(x .* conj(x)); % one approach


>> Ex = sum(abs(x) .^2); % another approach

Page 3 of 4
9. Signal power:
The average power of a periodic sequence with fundamental period N is given by

N −1
1
Px = ∑ x ( n)
2

N n=0
Problems:

1. Generate and plot each of the following sequences over the indicated interval. Also
calculate energy and power of these signals.

a. x( n) = 2δ ( n + 2) − δ (n − 4), − 5 ≤ n ≤ 5.
b. x( n) = n [ u ( n) − u ( n − 10)] + 10 e −0.3( n −10 ) [u (n − 10) − u (n − 20)], − 20 ≤ n ≤ 20

x ( n) = cos(0.04π n) + 0.2 w( n), 0 ≤ n ≤ 50, where w( n) is a Gaussian random sequence


c.
with zero mean and unit variance.
d. x% ( n) = {...,5, 4,3, 2,1,5, 4,3, 2,1,5, 4,3, 2,1,...}; − 10 ≤ n ≤ 9.

2. x( n) = {1, 2,3, 4,5, 6, 7, 6,5, 4,3, 2,1}. Determine and plot the following sequence.

a. x1 (n) = 2 x(n − 5) − 3x(n + 4)


b. x2 (n) = x(3 − n) + x(n) x(n − 2)

Page 4 of 4

You might also like