Digital Signal Processing Reference
In-Depth Information
>> subplot(3,1,3)
>> stem(n3,y); plots the output vector
y
• Vector approach
The vector approach is a more compact and more efficient from of
MATLAB programming
>> n1 = 0:4
>> x = 0.8
.
^ n1
>> n2 = 0:9
>> h = 0.5
.
^ n2
>> y = conv(x,h)
>> k1 = size(n1) + size(n2)-1
>> k = 0:k1-1
>> subplot(3,1,1); divides the page into 3 rows and
1 column format
>> stem(n1,x); plots the input vector
x
>> subplot(3,1,2)
>> stem(n2,h); plots the impulse response vector
h
>> subplot(3,1,3)
>> stem(k,y); plots the output vector
y
N
OTE
:
The output vector
y
will be of length 14. In general, if the vector
x
is
of length
N
, and the vector
h
is of length
M
, then the output vector
y
is of
length
N + M -
1.
Exercise 2: Plotting of continuous-time and discrete-time signals
a.
Plot the following continuous-time signals in the range -5
≤
t
≤
5 seconds.
i.
a.
x
(
t
) = 5 sin(10
t
) + 10 sin(20
t
)
ii.
b.
x
(
t
) = 2
e
-(
a t
2
)
,
a
= 0.1
b.
Plot the following discrete-time signals in the range -5
≤
n
≤
5.
i.
a.
x
(
n
)
=
0.8
n
u
(
n
)
ii.
b.
x
(
n
) = [sin(0.1
π
n
)]/
π
n
Exercise 3: Discrete-time convolution
Find the system output
y
(
n
), 0
≤
n
≤
10, of a LTI system when the input
x
(
n
)
=
(
n
- 3), and the impulse response
h
(
n
)
=
(0.5)
n
[
u
(
n
)
-
u
(
n -
5)]. Write a concise MATLAB program, using vector approach to model
the output,
y
(
n
), of the system, for the given input. Plot the vectors
x
,
h
, and
y
on the same page using subplot commands.
δ
(
n
)
+
3
δ
(
n
- 1)
+
4
δ