ch03.pdf

In the name of Allah
Chapter 3
There are three new main functions for this chapter, related to the discrete-time
functions, you will not use them in this exercise, but they are necessary
for next chapters and thus it is beneficial to see them now.
fft
ifft
freqz
fft:
For a signal x[n] with fundamental period N, the associated series representations
ak are periodic in k with period N. If x is an N-point vector containing x[ n ] with single
period 0 ≤ n ≤ N -1, then the expression a = ( 1 / N ) * fft( x ) computes the series
representations ak for 0 ≤ k ≤ N -1 in vector a with length N as its output.
Example:
>> x = [0 1 0]; (i.e. N = 3)
>> a = (1 / length(x)) * fft(x)
a=
0.3333
-0.1667 - 0.2887i
-0.1667 + 0.2887i
You know that the exact values are a = [ 1/3, -1/6 -√3/6 i, -1/6 +√3/6 i ]
ifft:
This function can be used to construct a vector containing x[ n ] for
0 ≤ n ≤ N -1 from a vector containing ak for 0 ≤ k ≤ N -1 as follow:
x = N * ifft( a ) .
Example:
>> a = [1/3, -1/6 – sqrt (3)/6 * i, -1/6 + sqrt(3)/6 * i ] ;
>> x = length (a) * ifft( a )
x=
0
1.0000
Computer exercises:
0.0000
1- Simulation of periodic square wave, Gibbs effect and parseval’s relation.
A) Assume x (t) is a square wave with T = 2, T1 = ½ and height = 1. Now
Suppose
xn (t ) =
n
∑a e ω
k =− n
k
k
0ti
ak =
sin( k ω 0 T 1)
kπ
2T 1
a =
0
T
Plot 4 functions of: x( t ), xn( t ) n = 4, 10, 40 for -1 ≤ t ≤ 1.
You may need commands sym, subs, subplot, ezplot . Plot all in one figure
using subplot, and name your mfile as: p3_1a.m
B) The expression
en =
n
∑a
k =− n
2
k
is an estimate for energy.
To observe how quickly the energy estimate converges, plot the estimate
of the signal energy as a function of terms used in the sum for 0 ≤ n ≤ 30.
You may find the function cumsum helpful to create a vector of the partial
sums. Name your mfile as: p3_1b.m
2- This exercise examines properties of the continuous-time Fourier series (CTFS)
representation for periodic continuous-time signals. Consider the signal
x1(t) = cos(ω0t) + sin(2ω0t ),
where ω0 = 2π. To evaluate this signal in MATLAB, use vector
>> t = linspace( -1, 1, 1000 );
which creates a vector of 1000 time samples over the region of -1 ≤ t ≤ 1.
a) What is the smallest period, T, for which x1(t) = x1(t + T)? Analytically
find the coefficients for the CTFS for x1(t) using this value of T.
b) Consider the signal y(t) = x1(t) + x1(- t). Using the time-reversal and
conjugation properties of the CTFS, determine the coefficients for
the CTFS of y(t).
c) Plot the signal y(t) over -1 ≤ t ≤ 1. What type of symmetry do you
expect ? Can you explain what you see in terms of the symmetry
properties of the CTFS?
d) Consider the signal z(t) = x1(t) – x1*(t) . Using the time-reversal and
conjugation properties of the CTFS, determine the coefficients for
the CTFS of z(t).
e) Plot the signal z(t) over -1 ≤ t ≤ 1. What type of symmetry do you
expect ? Can you explain what you see in terms of the symmetry
properties of the CTFS?
f) Repeat parts (a)–(e) using
x2(t) = cos(ω0t) + i sin(2ω0t ),
Note that x2(t) is complex. When plotting x2(t), y(t), and z(t), be
Be sure to plot the real and imaginary parts separately and note
the symmetry that you see in each.
Name your mfiles as: p3_21.m for x1& p3_22.m for x2.
Deadline: 82/8/18
No paper is required for computer exercises. Just Zip them and
send.
[email protected]