Docsity

Analysis of a Periodic Signal using Discrete Fourier Transform (DFT) - Prof. Aldo Ferri, Study notes of Computer Science

Toggle sidebar
bg1
ME2016, Dr. Ferri
DFT Example
Consider the function
)tcos(.)tsin(.)tcos()tsin(.)tcos(..)t(f 38024023075050
+
−
+
−+=
From this expression it is evident that a0 = 1.0, a1 = 0.75, b1 = -0.3, a2 = 1, b2 = -0.4, a3 = 0.8. The
function is created using the following Matlab code and is plotted below using N=256 points over a
time period of 2π seconds.
N=256;
delt=2*pi/N;
T=N*delt;
t=0:delt:(N-1)*delt;
a0=1.0; a1=0.75; b1=-0.3; a3=0.8; a2=1; b2=-.4;
f=a0/2+a1*cos(t)+b1*sin(t)+a2*cos(2*t)+b2*sin(2*t)+a3*cos(3*t);
plot(t,f); xlabel('t'); ylabel('f')
01234567
-1.5
-1
-0.5
0
0.5
1
1.5
2
2.5
3
3.5
t
f
In this case, T = 2π, thus 0
ω
= 2π/T = 1 rad/s.
The first 11 DFT values are calculated using the following Matlab commands:
pf3
pf4
pf5

Partial preview of the text

Download Analysis of a Periodic Signal using Discrete Fourier Transform (DFT) - Prof. Aldo Ferri and more Study notes Computer Science in PDF only on Docsity!

ME2016, Dr. Ferri DFT Example

Consider the function

f (t) = 0_._ 5 + 0_._ 75 cos(t) − 0_._ 3 sin(t) + cos( 2 t) − 0_._ 4 sin( 2 t) + 0_._ 8 cos( 3 t )

From this expression it is evident that a 0 = 1.0, a 1 = 0.75, b 1 = -0.3, a 2 = 1, b 2 = -0.4, a 3 = 0.8. The function is created using the following Matlab code and is plotted below using N=256 points over a time period of 2π seconds.

N=256; delt=2pi/N; T=Ndelt; t=0:delt:(N-1)delt; a0=1.0; a1=0.75; b1=-0.3; a3=0.8; a2=1; b2=-.4; f=a0/2+a1cos(t)+b1sin(t)+a2cos(2t)+b2sin(2t)+a3cos(3*t);

plot(t,f); xlabel('t'); ylabel('f')

0 1 2 3 4 5 6 7

-1.

-0.

0

1

2

3

t

f

In this case, T = 2π, thus ω 0 = 2π/T = 1 rad/s.

The first 11 DFT values are calculated using the following Matlab commands:

for k=1:11; F(k) = 0; for r=1:N; angle = (k-1)(2pi/N)(r-1); F(k) = F(k) + f(r)exp(-i*angle); end end

Note that the index k goes from 1 to 11, which corresponds to the subscript k (in, for example, fk and Fk) going from 0 to 10. In tabular form, the first 11 values of F are given by:

k k ω 0 Real(Fk ) Imag(Fk ) 0 0.0 128.0 0 1 1.0 96.0 38. 2 2.0 128.0 51. 3 3.0 102.4 0 4 4.0 0 0 5 5.0 0 0 6 6.0 0 0 7 7.0 0 0 8 8.0 0 0 9 9.0 0 0 10 10.0 0 0

These 11 complex values Fk are identical to those that would have been obtained using the Matlab

fft.m command: >> F=fft(f). The magnitude of F is plotted vs the frequency (k ω 0 ) in rad/s

below.

0 1 2 3 4 5 6 7 8 9 10

0

20

40

60

80

100

120

140

Frequency (rad/s)

DFT

DFT Based on exact freq. amps

Aperiodic Signal Often, we use FFT’s to analyze systems that don’t repeat. For example, we can have a signal that is zero after some transient event is over. Here, we consider a unit pulse of duration 5/16 sec., followed by zero values for t > 5/16 sec; the signal is said to be “padded with zeros” beyond 5/ sec. Using a sampling interval of 1/16 sec, and N = 16 samples, the signal is as shown below. Although the true signal is zero for t > 1 sec, the FFT has no way to know that, and it assumes that it repeats with period 1 sec. The signal, shown plotted below, can be generated using the commands

t=0:(1/16):15/16; f=[1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0];

(^00) 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

1

Time (sec)

f

The DFT of the signal can be calculated using the Matlab command >> F=fft(f); The magnitude of the DFT of f is shown below. Note that the magnitude plot is symmetric about the 9th point since N/2 = 8, which corresponds to the 9th^ element in the vector F.

0 10 20 30 40 50 60 70 80 90 100 0

1

2

3

4

5

Frequency (rad/s)

Magnitude of F

The DFT is also given in tabular form below

Note that, as before, FN-k = conj( Fk ) for k = 1 to 7. Also, note that FN/2 = F 8 is real valued. The

  • 0 5.0000 k Real(Fk ) Imag(Fk )
  • 1 3.0137 -3.
  • 2 -0.0000 -2.
  • 3 -0.2483 -0.
  • 4 1.0000
  • 5 0.8341 -0.
  • 6 0.0000 -0.
  • 7 0.4005 0.
  • 8 1.0000
  • 9 0.4005 -0.
  • 10 0.0000 0.
  • 11 0.8341 0.
  • 12 1.0000
  • 13 -0.2483 0.
  • 14 -0.0000 2.
  • 15 3.0137 3.