Digital Signal Processing Reference
In-Depth Information
Once we have a sampled sine wave, we can mathematically express it without reference to the
sampling period by defining the sequence length as N . We would then have, in general,
s
[
n
]=
sin
[
2 πnk/N
]
where n is the sample index, which runs from 0 to N
1, and k is the number of cycles over the sequence
length N . For the sample sequence marked in Fig. 2.1, we would have
]
where we have noted that there are two full cycles of the sine over 16 samples (the 17th sample is the start
of the third cycle). The correctness of this formula can be verified by noting that for the 17th sample, n =
16, and s
s
[
n
]=
sin
[
2 πn 2 / 16
[
16
]
= 0, as shown. Picking another sample, for n =2,weget s
[
2
]
= sin
[
2 π( 2 ) 2 / 16
]
= sin
[
π/ 2
]
= 1, as shown.
A phase angle is sometimes needed, and is denoted θ by in the following expression:
s
[
n
]=
sin
[
2 πnk/N
+
θ
]
Note that if θ = π/ 2, then
]
We can illustrate this by generating and displaying a sine wave having three cycles over 18 samples,
then the same sine wave, but with a phase angle of π/ 2 radians, and finally a cosine wave having three
cycles over 18 samples and a zero phase angle. A suitable MathScript call, which results in Fig. 2.3, is
n = 0:1:17; y1 = sin(2*pi*n/18*3); subplot(311); stem(n,y1);
y2 = sin(2*pi*n/18*3 +pi/2); subplot(312); stem(n,y2);
y3 = cos(2*pi*n/18*3); subplot(313); stem(n,y3)
s
[
n
]=
cos
[
2 πnk/N
2.4.2 SEQUENCE AND TIME POSITION VECTOR
Certain operations on two sequences, such as addition and multiplication, require that the sequences be
of equal length, and that their proper positions in time be preserved.
Consider the sequence x 1 = [1,2,3,4], which was sampled at sample time indices n 1 = [-1,0,1,2],
which we would like to add to sequence x 2 = [4,3,2,1], which was sampled at time indices n 2 = [2,3,4,5].
To make these two sequences equal in length, we'll prepend and postpend zeros as needed to result in
two sequences of equal length that retain the proper time alignment. We see that the minimum time
index is -1 and the maximum time index is 5. Since x 1 starts at the minimum time index, we postpend
zeros to it such that we would have x 1 = [1,2,3,4,0,0,0], with corresponding time indices [-1,0,1,2,3,4,5].
Similarly, we prepend zeros so that x 2 = [0,0,0,4,3,2,1], with the same total time or sample index range
as the modified version of x 1. Figure 2.4 depicts this process.
The sum is then
x 1
+
x 2
=
[1,2,3,4,0,0,0] + [0,0,0,4,3,2,1] = [1,2,3,8,3,2,1]
and has time indices [-1,0,1,2,3,4,5].
These two ideas, that sequences to be added or multiplied must be of equal length, but also properly
time-aligned, lead us to write several MathScript functions that will automatically perform the needed
adjustments and perform the arithmetic operation.
Search WWH ::




Custom Search