Lab 08: Fourier Transform
Lab 08: Fourier Transform
Program 1
Example 1: The typical syntax for computing the FFT of a signal is FFT(x,N) where x is
the signal, x[n], you wish to transform, and N is the number of points in the FFT. N must
be at least as large as the number of samples in x[n]. To demonstrate the effect of
changing the value of N, sythesize a cosine signal with 30 samples at 10 samples per
period.
n = [0:29];
x = cos(2*pi*n/10);
Define 3 different values for N and take the transform of x[n] for each of these 3 values.
The abs function finds the magnitude of the transform, as we are not concerned with
distinguishing between real and imaginary components.
N1 = 64;
N2 = 128;
N3 = 256;
X1 = abs(fft(x,N1));
X2 = abs(fft(x,N2));
X3 = abs(fft(x,N3));
The frequency scale begins at 0 and extends to N - 1 for an N-point FFT. We then
normalize the scale so that it extends from 0 to 1-1/N.
F1 = [0 : N1 - 1]/N1;
F2 = [0 : N2 - 1]/N2;
F3 = [0 : N3 - 1]/N3;
figure(1);
subplot(3,1,1)
plot(F1,X1,'-x'),title('N = 64'),axis([0 1 0 20])
subplot(3,1,2)
plot(F2,X2,'-x'),title('N = 128'),axis([0 1 0 20])
subplot(3,1,3)
plot(F3,X3,'-x'),title('N = 256'),axis([0 1 0 20])
1
Signals and Systems Lab DEE, FURC
Upon examining the plot (shown in figure 2) one can see that each of the transforms
adheres to the same shape, differing only in the number of samples used to approximate
that shape. What happens if N is the same as the number of samples in x[n]? To find out,
set N1 = 30. What does the resulting plot look like?
N4=30;
X4=abs(fft(x,N4));
F4 = [0 : N4 - 1]/N4;
figure(2);
plot(F4,X4,'-x'),title('N = 30'),axis([0 1 0 20])
Program 2
y[n]-3/4y[n-1]+1/8y[n-2]=x[n]
5. H = tf(num,den)
6. Now to find the roots of the numerator and the denominator we can use the
command below; these steps will help us to find the impulse response.
2
Signals and Systems Lab DEE, FURC
7. Finally to find Y(W) for a given X(W), we need to multiply the X(W) with H(W)
that we found previously. Consider X(W)= 1/(0.4s+1), firstly we need to find the
transfer function for X and then multiply that by H.
X = tf([1],[0.4 1])
Y=H*X
8. And to find the impulse response, we can use the conversion table, to convert the
frequency response signal from frequency to time domain impulse response.
a
ae bt u (t )
1 bs
So, by using Matlab we proved that the result was the same with the one we found by
calculation. The example here was an easy function that could be done easily by
calculation, in the case of complex functions, we can simply use the commands stated
above to find the roots and so finally the 'h' in time domain.