Você está na página 1de 2

Department of Electrical and Electronics Engineering

Signals and Systems


EE -MATLAB Exercises 4
1 Introduction
This assignment gives Matlab examples for the material covered in chapter 3 of class lecture.
This exercise builds on the previous Matlab exercises, so please have a look at them if you have
not already done so.
2 Discrete-Time Fourier Transform
Chapter 3 of the Lecture Notes covers the discrete-time Fourier transform. We will be using the
fft and ifft functions, which we discussed in exercise 3 as approximations to the continuous-time
Fourier transform. Now, we will use fft and ifft to calculate samples of the exact discrete-time
Fourier transforms of signals.
As we can see from the discrete-time Fourier transform definition studied in class, the Fourier
spectrum X(ej) is a continuous function. The Matlab functions
fft and ifft return a sampled version of X(ej) over the range 0 2 .
2.1 Exercising the Discrete-time Fourier Transform
We will first investigate the Fourier transform of a simple rectangular-wave signal, defined as:
x ( n )=u ( n )u (n5)
We know that

x ( n ) is non-zero over the range 0 n 4. Lets create this signal in Matlab, and

examine the spectrum:


>> len = 100;
>> n = 0:1:len-1;
>> x = zeros(1,len);
>> x([0:1:4]+1) = 1;
Recall that Matlab vectors are indexed starting at 1, so x ( 1 )

corresponds to n = 0. We can

verify this is the correct signal:


>> stem(n,x);
Now, we will examine the Fourier spectrum of this signal:
>> G = fft(x);
>> w = linspace(0,2*pi,len);
Note that fft will return len equally-spaced samples of the Fourier spectrum of

x (n) over the

range 0 2. Lets examine the shape of the spectrum:


>> stem(w,G);
This results in a relatively finely-sampled version of the spectrum X(ej). Lets briefly examine
the effect of changing the number of samples of x(n):
>> len = 20;
>> n = 0:1:len-1;
>> x = zeros(1,len);
>> x([0:1:4]+1) = 1;

>> G = fft(x);
>> w = linspace(0,2*pi,len);
>> stem(w,G);
As is expected, this results in a more coarsely-sampled version of X(ej).
3 Discrete-time Fourier Transform Properties
In this section, we will look at two of the Fourier transform properties. We will use signal x(n)
from the previous section. Recall the Matlab code to create this signal and calculate its spectrum:
>> len = 100;
>> n = 0:1:len-1;
>> w = linspace(0,2*pi,len);
>> x = zeros(1,len);
>> x([0:1:4]+1) = 1;
>> G = fft(x);
3.1 Time shifting
In this section we consider the time shift property discussed in class. Lets create a new signal
shifted by n0 = 10:
>> y = [zeros(1,10) x(1,90)];
Now, we can calculate both the response of this signal (H):
>> H = fft(y);
Finally, we can plot frequency response:
>> figure(1);
>> stem(w,H);
We observe that the time-shifting property holds.
3.2 Frequency Shifting
In this section we consider the frequency shift property. First we multiply x(n) by a complex
exponential with o = /3:
y = exp(-j*pi/3*n).*x;
H = fft(y);
Now, we can plot both the original and new frequency responses:
>> figure(1);
>> stem(w,G);
>> figure(2);
>> stem(w,H);
You should observe from these plots that the frequency spectrum of y(n) is indeed shifted by an
amount o = /3.

Você também pode gostar