Lesson 11111
Lesson 11111
MATLAB
T.N.Kaputu
1
How to Represent a Discrete Time Signal in MATLAB
>> n=[-3,-2,-1,0,1,2,3,4];
x=[2,1,-1,0,1,4,3,7];
2
TYPES OF SEQUENCES
3
TYPES OF SEQUENCES
4
TYPES OF SEQUENCES
5
TYPES OF SEQUENCES
6
TYPES OF SEQUENCES
n = [0:10];
x = (0.9).^n;
stem(n,x)
7
TYPES OF SEQUENCES
Sinusoidal sequence:
example
n = [0:10];
x = 3*cos(0.1*pi*n+pi/3) + 2*sin(0.5*pi*n);
stem(n,x)
8
OPERATIONS ON SEQUENCES
𝑛2
𝑦 𝑛 = 𝑥 𝑛1 + 𝑥 𝑛1 + 1 + ⋯ + 𝑥 𝑛2
𝑛=𝑛1
Note that the result of this type of sample summation is a scalar value, not a
signal (i.e. the time index is lost since we’ve summed over it). Summation is
performed in Matlab using the “sum” function. For instance
y=sum(x)
will give the sum of all the samples stored in the vector x
9
OPERATIONS ON SEQUENCES
Signal addition:
This is a sample-by-sample addition given by
𝑥1 𝑛 + 𝑥2 𝑛 = 𝑥1 𝑛 + 𝑥2 𝑛
function [y,n] = sigadd(x1,n1,x2,n2)
Scaling:
In this operation each sample is multiplied by a scalar α.
𝛼 𝑥𝑛 = 𝛼{𝑥(𝑛)}
12
OPERATIONS ON SEQUENCES
Shifting
In this operation, each sample of 𝑥(𝑛) is shifted by an amount 𝑘 to obtain a
shifted sequence 𝑦(𝑛).
𝑦 𝑚 + 𝑘 = {𝑥(𝑚)}
n = m+k;
y = x;
13
OPERATIONS ON SEQUENCES
Folding:
In this operation each sample of x(n) is flipped around n = 0
to obtain a folded sequence y(n)
𝑦 𝑛 = {𝑥(−𝑛)}
14
Exercise 1
Generate and plot each of the following sequences over the indicated interval.
15
Exercise 2
16
Homework
17
Homework
18
19