from fourier series to analysis of non-stationary signals

Post on 24-Mar-2022

0 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

From Fourier Series to Analysis of

Non-stationary Signals – IV

Mathematical tools, 2019

Jan Prikryl, Miroslav Vlcek

October 21, 2019

Department of Applied Mathematics, CTU FTS

Contents

Trigonometric formulae

Vector space of continuous basic waveforms

Vector space of discrete basic waveforms

Discrete Fourier Transform – DFT

Project

Homework

1

Contents

Trigonometric formulae

Vector space of continuous basic waveforms

Vector space of discrete basic waveforms

Discrete Fourier Transform – DFT

Project

Homework

1

Contents

Trigonometric formulae

Vector space of continuous basic waveforms

Vector space of discrete basic waveforms

Discrete Fourier Transform – DFT

Project

Homework

1

Contents

Trigonometric formulae

Vector space of continuous basic waveforms

Vector space of discrete basic waveforms

Discrete Fourier Transform – DFT

Project

Homework

1

Contents

Trigonometric formulae

Vector space of continuous basic waveforms

Vector space of discrete basic waveforms

Discrete Fourier Transform – DFT

Project

Homework

1

Contents

Trigonometric formulae

Vector space of continuous basic waveforms

Vector space of discrete basic waveforms

Discrete Fourier Transform – DFT

Project

Homework

1

Trigonometric formulae

Integrals of trigonometric functions

The derivatives and integrals (as primitive functions) of

trigonometric functions are interconnected:

d

dxsin `x = ` cos `x ⇒

∫cos `x dx =

1

`sin `x ,

d

dxcos `x = −` sin `x ⇒

∫sin `x dx = −1

`cos `x .

2

Product of trigonometric functions

Products of two trigonometric functions are expressible as

2 sin `x sinmx = cos(`−m)x − cos(`+ m)x ,

2 cos `x cosmx = cos(`−m)x + cos(`+ m)x ,

2 sin `x cosmx = sin(`−m)x + sin(`+ m)x

Note

If x ∈ (0, 2π) then for x = ω0t we have t ∈ (0,T ).

We have learnt that trigonometric functions cosmω0t and

sinmω0t form Fourier basis for T -periodic functions.

Question

Is the basis cosmx and sinmx orthogonal?

3

Orthogonal basis

We will study the scalar inner products of these functions for

` 6= m first:

(cos `x , cosmx) =

∫ 2π

0cos `x cosmx dx

=1

2

∫ 2π

0cos(`−m)x dx +

1

2

∫ 2π

0cos(`+ m)x dx

=1

2(`−m)

[sin(`−m)x

]2π0

+1

2(`+ m)

[sin(`+ m)x

]2π0

=0− 0

2(`−m)+

0− 0

2(`+ m)= 0

4

Orthogonal basis

(sin `x , sinmx) =

∫ 2π

0sin `x sinmx dx

=1

2

∫ 2π

0cos(`−m)x dx − 1

2

∫ 2π

0cos(`+ m)x dx

=1

2(`−m)

[sin(`−m)x

]2π0− 1

2(`+ m)

[sin(`+ m)x

]2π0

=0− 0

2(`−m)− 0− 0

2(`+ m)= 0

5

Orthogonal basis

(sin `x , cosmx) =

∫ 2π

0sin `x cosmx dx

=1

2

∫ 2π

0sin(`−m)x dx +

1

2

∫ 2π

0sin(`+ m)x dx

= − 1

2(`−m)

[cos(`−m)x

]2π0− 1

2(`+ m)

[cos(`+ m)x

]2π0

= − 1− 1

2(`−m)− 1− 1

2(`+ m)= 0

(sinmx , cosmx) =1

2

∫ 2π

0sin 2mx dx

= − 1

4m

[cos 2mx

]2π0

= 0 for ` = m

6

Normalization

We will study the case ` = m separately

(cosmx , cosmx) =

∫ 2π

0cos2mx dx =

∫ 2π

0

1 + cos 2mx

2dx

=1

2[x ]2π0 +

1

2m[sin 2mx ]2π0

|| cosmx ||2 = π || cosmω0t||2 =T

2

(sinmx , sinmx) =

∫ 2π

0sin2mx dx =

∫ 2π

0

1− cos 2mx

2dx

=1

2[x ]2π0 −

1

2m[sin 2mx ]2π0

|| sinmx ||2 = π || sinmω0t||2 =T

2 7

Vector space of continuous basic

waveforms

Trigonometric Fourier Series

1. T -periodic signal x(t) representation:

x(t) = a0 +∞∑k=1

ak cos(kω0t) +∞∑k=1

bk sin(kω0t)

2. basis vectors cos(kω0t), sin(kω0t)

3. a0 =1

T

∫ T

0x(t) dt,

ak =(x(t), cos(kω0t))

(cos(kω0t), cos(kω0t))≡ 2

T

∫ T

0x(t) cos(kω0t) dt

4. bk =(x(t), sin(kω0t))

(sin(kω0t), sin(kω0t))≡ 2

T

∫ T

0x(t) sin(kω0t) dt

8

Continuous signal and basis vectors

1. T -periodic signal representation x(t) =∞∑

k=−∞ck exp(j kω0t)

2. basis vector φk(t) = exp(j kω0t)

3. scalar product

ck =(x(t), φk(t))

(φk(t), φk(t))≡ 1

T

∫ T

0x(t) exp(−j kω0t))dt

4. completness of basis vectors

(φk(t), φ`(t)) =1

T

∫ T

0exp(j kω0t) exp(−j `ω0t)dt = δk,`

9

Continuous signal and basis vectors

1. Fourier series x(t) =∞∑

k=−∞ck exp(j kω0t)

2. Partial sum of Fourier Series xN(t) =M∑

k=−Mck exp(j kω0t) for

N = 2M + 1

10

Dirichlet kernel

Definition (Dirichlet kernel)

Dirichlet kernels are the partial sums of exponential functions

DM(ω0t) =M∑

k=−Mexp(j kω0t) = 1 + 2

M∑k=1

cos(kω0t).

Show that DM(ω0t) =sin((M + 1/2)ω0t)

sin(ω0t/2).

11

Dirichlet kernel

Theorem (Convolution of Dirichlet kernel)

The convolution of DM(t) with an arbitrary T -periodic function

f (t) = f (t + T ) is the M-th degree Fourier series approximation to

f (t).

DM(t) ∗ f (t) ≡ 1

T

∫ T/2

−T/2DM(t − τ)f (τ)dτ =

M∑k=−M

ck exp(j kω0t),

where ck =1

T

∫ T/2

−T/2f (t) exp(−j kω0t) dt.

12

Vector space of discrete basic

waveforms

Discrete signal and basis vectors

Consider a continuous signal x(t) defined as T -periodical signal,

sampled at the N times t = nT/N for n = 0, 1, 2, . . . ,N − 1. This

yields discretised signal

x = (x0, x1, x2 . . . , xN−1)

where x is a vector in RN with N components xn = x(nT/N). The

sampled signal x = (x0, x1, x2 . . . , xN−1) can be extended

periodically with period N by modular definition

xm = xmmodN

for all m outside the range 0 ≤ m ≤ N − 1.

13

Discrete signal and basis vectors

In order to form the discrete basis vectors we substitute in

φk(t) = exp(jkω0t) = exp

(j2πkt

T

)the discrete time t = nT/N yielding N components of the basis

vector

φk,n ≡ φk(nT

N

)= exp

(j2πkn

N

).

14

Discrete signal and basis vectors

Basis vector has complex components

φk =

exp(j 2π k0

N )

exp(j 2π k1N )

exp(j 2π k2N )

...

exp(j 2π k(N−1)N )

15

Discrete signal and basis vectors

On Cn the usual scalar (inner) product is

(x, y) = x1y1 + x2y2 + . . .+ xnyn

The corresponding norm is

||x||2 = (x, x) = x1x1 +x2x2 + . . .+xnxn = |x1|2 + |x1|2 + . . .+ |xn|2

which translates for our basis vector to

||φk ||2 = φk,0φk,0 + φk,1φk,1 + . . .+ φk,N−1φk,N−1

= 1 + 1 + . . .+ 1 = N

as φk,n = exp(−j 2πknN ) is a complex conjugate to

φk,n = exp(j 2πknN ).

16

Discrete signal and basis vectors

We can prove that basis vectors are orthogonal using scalar

product (φk ,φ`) is zero for k 6= `. Actually

(φk ,φ`) =N−1∑ν=0

φk,νφ`,ν =N−1∑ν=0

exp(j2π (k − `) ν

N) =

=N−1∑ν=0

(exp(j

2π (k − `)N

)

)ν.

We have arrived to geometric series. Its partial sum for k 6= ` is

(φk ,φ`) =1−

(exp(j 2π (k−`)

N ))N

1− exp(j 2π (k−`)N )

=1− exp(j2π (k − `))

1− exp(j 2π (k−`)N )

= 0

17

Discrete Fourier Transform – DFT

Definition of the DFT

1. Let x ∈ CN be a vector (x0, x1, x2, . . . , xN−1). The discrete

Fourier transform (DFT) of x is the vector X ∈ CN with

components

Xk = (x,Φk) =N−1∑m=0

xm exp(−j 2π k m

N).

2. Let X ∈ CN be a vector (X0,X1,X2, . . . ,XN−1). The inverse

discrete Fourier transform (IDFT) of X is the vector x ∈ CN

with components

xk =(X,Φ−k)

(Φk ,Φk)=

1

N

N−1∑m=0

Xm exp(j2π k m

N).

18

Definition of the DFT

The coefficient X0/N measures the contribution of the basic

waveform (1, 1, 1, . . . , 1) to x. In fact

X0

N=

1

N

N−1∑m=0

xm

is the average value of x.This coefficient is usually called as the dc

coefficient, because it measures the strength of the direct current

component of a signal.

19

Project

Application of the DFT

ExampleConsider the analog signal

x(t) = 2.0 cos(2π 5t) + 0.8 sin(2π 12t) + 0.3 cos(2π 47t)

on the interval t ∈ (0, 1). Sample this signal with period

τ = 1/128 s and obtain sample vector x = (x0, x1, x2, . . . , x127).

1. Make MATLAB m-file which plots signals x(t) and x

2. Using definition of the DFT find X.

3. Use MATLAB command fft(x) to compute DFT of X.

4. Make MATLAB m-file which computes DFT of x and plots

signal and its spectrum.

5. Compute IDFT of the X and compare it with the original

signal x(t).

20

Example 1: Signal plots

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−3

−2

−1

0

1

2

3

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−3

−2

−1

0

1

2

3

Discrete signal x(n)Continuous signal x(t)

21

Solution of example 1

clear

% plots original and sampled signal

t = linspace(0,1,1001);

x = 2.0*cos(2*pi*5*t) + 0.8*sin(2*pi*12*t) + ...

0.3*cos(2*pi*47*t);

N = 128; % number of samples

tdelta = 1/N; % sampling period

ts(1) = 0;

xs(1) = x(1);

for k = 2:1:N

ts(k) = (k-1)*tdelta;

xs(k) = 2.0*cos(2*pi*5*(k-1)*tdelta) + ...

0.8*sin(2*pi*12*(k-1)*tdelta) + ...

0.3*cos(2*pi*47*(k-1)*tdelta);

end 22

Solution of example 1

figure(1);

subplot(2,1,1);

plot(t,x,’LineWidth’,2.5,’Color’,[1 0 0]);

grid on;

subplot(2,1,2);

plot(ts, xs,’o’,’LineWidth’,2.0,’Color’,[0 0 1]);

hold on;

plot(t,x,’--’,’Color’,[1 0 0]);

grid on;

legend(’Discrete signal x(n)’,’Continuous signal x(t)’);

hold off;

pause

23

Homework

Analysis of audio signal

• Start MATLAB. Load in the “ding” audio signal with command

y=wavread(’ding.wav’); The audio signal is stereo one and can

be decoupled into two channels by y1=y(:,1); y2=y(:,2);. The

sampling rate is 22 050 Herz, and the signal contains 20 191

samples. If we consider this signal as sampled on an interval

(0,T ), then T = 20191/22050 ≈ 0.9157 seconds.

• Compute the DFT of the signal with Y1=fft(y1); and

Y2=fft(y2);. Display the magnitude of the Fourier transform

with plot(abs(Y1)) or plot(abs(Y2)). The DFT is of length

20 191 and symmetric about center.

24

MATLAB project with audio signal

• Since MATLAB indexes from 1, the DFT coefficient Yk is actually

Y(k+1) in MATLAB ! Also Yk corresponds to frequency

k/T = k/0.9157 and so Y(k+1) corresponds to

fk = (k − 1)/T = (k − 1)/0.9157.

• You can plot only the first half of the DFT with

plot(abs(Y1(1:6441))) or plot(abs(Y2(1:6441))). Use the

data cursor button on plot window to pick out the frequency and

amplitude of the two (obviously) largest components in the

spectrum. Compute the actual value of each significant frequency

in Herz.

25

MATLAB project with audio signal

• Let f1, f2 denote these frequencies in Herz, and let A1,A2 denote

the corresponding amplitudes from the plot. Define these variables

in MATLAB.

• Generate a new signal using only these frequencies, sampled at 22

050 Herz on the interval (0, 1) with

t = [0:1/22050:1];

y12 = (A1*sin(2*pi*f1*t) + A2*sin(2*pi*f2*t))/(A1+A2)

• Play the original sound with sound(y1) and the synthesized

version sound(y12). Repeat the experiment with sound of the

second channel sound(y2). Note that our synthesis does not take

into account the phase information at these frequencies.

• Does the artificial generated signal reproduce ding.wav correctly?

Compare the quality!

26

top related