• No results found

Suggested solutions to exam in TSRT78 Digital Signal Processing

N/A
N/A
Protected

Academic year: 2022

Share "Suggested solutions to exam in TSRT78 Digital Signal Processing"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

Suggested solutions to exam in TSRT78 Digital Signal Processing 20200113

January 9, 2020

1. (a) The notch filter stops the signal components around frequency ω0 to pass through filter. As β → 1 and poles get closer to the unit circle, the narrower the stop-band becomes. See Fig. 1 for a illustration of the frequency and phase response when β = 0.95 and β = 0.99, respectively. Rewriting the filter transfer function as

H(z) = (z − e0)(z − e−jω0)

(z − βe0)(z − βe−jω0) = 1 − (e0 + e−jω0)z−1+ z−2

1 − β(e0+ e−jω0)z−1+ β2z−2 = 1 − 2 cos(ω0)z−1+ z−2 1 − 2β cos(ω0)z−1+ β2z−2 Then the following code can be used to plot the frequency function

Fs=22050;

w0=0.5;

beta=0.99;

B=[1 -2*cos(w0) 1];

A=[1 -2*beta*cos(w0) beta^2];

H1=freqz(B,A,1024);

beta=0.95;

B=[1 -2*cos(w0) 1];

A=[1 -2*beta*cos(w0) beta^2];

H2=freqz(B,A,1024);

f=(0:1023)./1024*Fs/2;

figure(1) clf

subplot(2,1,1) plot(f,abs(H1));

hold on;

plot(f,abs(H2));

grid minor

xlabel(’Freq. [Hz]’)

ylabel(’|H(e^{j2pi f/fs}|’)

legend(’\beta=0.99’,’\beta=0.95’) subplot(2,1,2)

plot(f,angle(H1));

hold on;

plot(f,angle(H2));

(2)

grid minor

xlabel(’Freq. [Hz]’)

ylabel(’\angle H(e^{j2pi f/fs})’)

(b) The following code can be used to plot the periodogram of the signal using Welch method.

load vuvuzela;

Fs=22050;

N=length(y); % Length of data

L=10; % Number of blocks to divide the data into K=floor(N/L); % Number of data points in each block

M=2^16; % Length of each FFT

f=(0:M-1)./M*Fs; % Frequency scale

% Welch method, i.e., average of spectrums Pyy=zeros(M,1);

for ii=1:L

Pyy=Pyy+abs(fft(y(K*(ii-1)+1:K*ii),M)).^2;

end

Pyy=Pyy./(M^2*L);

figure(2) clf

plot(f(1:M/2),10*log10(Pyy(1:M/2))) grid on;

xlabel(’Freq. [Hz]’) ylabel(’P_{yy} [dB]’) hold on;

The resulting spectrum estimate is shown in Fig. 2, where the strongest tone has a frequency of approximately 390 Hz.

(c) then the following code can be used to filter the signal through the notch filter.

Fs=22050;

w0=2*pi*390/Fs;

B=[1 -2*cos(w0) 1];

A=[1 -2*beta*cos(w0) beta^2];

y2=filtfilt(B,A,y);

The spectrum estimate of the filtered signal when β = 0.95 is shown in Fig. 2.

(3)

0 2000 4000 6000 8000 10000 12000 Freq. [Hz]

0 0.5 1

|H(ej2pi f/fs|

=0.99

=0.95

0 2000 4000 6000 8000 10000 12000

Freq. [Hz]

-2 -1 0 1 2

H(ej2pi f/fs )

Figure 1: Frequency and phase response of the notch filter.

0 2000 4000 6000 8000 10000 12000

Freq. [Hz]

-130 -120 -110 -100 -90 -80 -70 -60 -50

P yy [dB]

before filtering after filtering X 388.9

Y -59.86

Figure 2: Periodogram of the vuvuzela signal before and after applying the notch filter.

(4)

2. (a) The signal model can in vector form be written as y = Ha + e, where

y =

 y0 y1 ... yN −1

 e =

 e0 e1 ... eN −1

 a =

 a1 a2 ... aK

H =

1 1 ... 1

sin(2πf0/fs) sin(4πf0/fs) ... sin(2Kπf0/fs) sin(4πf0/fs) sin(8πf0/fs) ... sin(4Kπf0/fs)

... ... ... ...

sin(2(N − 1)πf0/fs) sin(4(N − 1)πf0/fs) ... sin(2K(N − 1)πf0/fs)

 Hence, the parameters can be estimated as ˆa = (H>H)−1H>y. The following Matlab code calculates the parameters for different model orders and the resulting AIC and BIC loss function (see e.q. (6.90) and e.q. (6.91) in the book for details).

load multisin;

f0=5; % Fundamental frequency

fs=1000; % Sampling frequency N=length(y); % Number of samples n=(0:N-1)’; % Time vector

K=20; % Maiximum model order

V=zeros(1,K); % Loss-function values for different model orders for k=1:K

% Build regression matrix H=zeros(N,k);

for ii=1:k

H(:,ii)=sin(2*pi*ii*f0/fs*n);

end

% Parameter estimate a_hat=H\y;

% Value of cost function res=y-H*a_hat;

(5)

xlabel(’Model order: K’)

The resulting loss-function, AIC, and BIC values are shown in Fig. 3

(b) Selecting a model order K = 5 gives the reconstructed signal ˆsnshown in Fig. 4. The following code generates the plot

% Build regression matrix H=zeros(N,5);

for ii=1:5

H(:,ii)=sin(2*pi*ii*f0/fs*n);

end

% Parameter estimate a_hat=H\y;

% Reconstruct the signal sh=zeros(N,1);

for k=1:length(a_hat)

sh=sh+a_hat(k)*sin(2*pi*k*f0/fs*n);

end

% Plot the signal figure(2)

clf

plot(n,y) hold on;

plot(n,sh,’r’) xlabel(’Sample: n’) ylabel(’Amplitude’)

legend(’Measured signal: y_n’,’Reconstructed signal: \hat{s}_n’)

(6)

0 2 4 6 8 10 12 14 16 18 20 Model order: K

3.5 3.6 3.7 3.8 3.9 4 4.1

Loss function AIC BIC

Figure 3: Loss function, AIC, and BIC values as a function of model order.

-4 -2 0 2 4 6 8

Amplitude

Measured signal: yn

Reconstructed signal: \hat{s}_n

(7)

3. (a) The frequency response of the stationary Kalman filter predictor is given by (see e.q.

8.28 in the book)

Hy ˆx(eiωTs) = (eiωTsI − A + A ¯KC)−1A ¯K (1) where the stationary Kalman gain ¯K = ¯P C>(C ¯P C>+ R)−1 and the stationary covariance ¯P is found by solving the Riccati equation.

P = A ¯¯ P A>− A ¯P C>(C ¯P C>+ R)−1C ¯P A>+ Q (2) With A = 0.8, Q = 0.62, and R = 1, this gives ¯P = 0.6, and the filter transfer function becomes

Hy ˆx(z) = 0.3 z − 0.5

The following code can be used to plot the frequency response shown in Fig. 5.

B=0.3;

A=[1 -0,5];

Fs=1;

H=freqz(B,A,1024);

f=(0:1023)./1024*Fs/2;

figure(1) clf

subplot(2,1,1) plot(f,abs(H));

grid minor

xlabel(’Freq. [Hz]’)

ylabel(’|H(e^{j2pi f/fs}|’) subplot(2,1,2)

plot(f,angle(H));

grid minor

xlabel(’Freq. [Hz]’)

ylabel(’\angle H(e^{j2pi f/fs})’)

(b) As for a stationary stochastic process the stationary Kalman filter predictor is equiva- lent to the causal Wiener filter predictor, they will have the same frequency response.

Following the derivations in example 7.7 in the book the filter transfer function can be found as follows.

Φyy(z) = 1.6

|{z}

σ2e

z − 0.5 z − 0.8

| {z }

T (z)

·z−1− 0.5 z−1− 0.8

| {z }

T (z−1)

xy(z)

σe2T (z−1) = zΦxx(z)

σe2T (z−1) = −0.45z2

(z − 0.8)(z − 2) = 0.3z z − 0.8

| {z }

causal part

+ −0.75z z − 2

| {z }

non-causal part

⇒ Hy ˆx(z) = 0.3z z − 0.8 ·1

z ·z − 0.8

z − 0.5 = 0.3 z − 0.5

(8)

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 Freq. [Hz]

0.05 0.06 0.07 0.08

|H(ej2pi f/fs|

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5

Freq. [Hz]

-4 -2 0 2 4

H(ej2pi f/fs )

Figure 5: Frequency response of the stationary Kalman filter predictor.

(9)

4. (a) The filter parameters (impulse response coefficients) that minimizes the mean squared error is given by the FIR Wiener filter. That is, the filter coefficients are given by the solution to (see e.q. (7.24) in the book)

Ryy(0) Ryy(1) Ryy(1) Ryy(0)

 h0

h1



=Rsy(0) Rsy(1)



where

Ryy(k) = /sk ⊥ vk/ = Rdd(k) + σ2vδ(k) = (−0.9)|k|σs2

1 − 0.92 + σv2δ(k) = (−0.9)|k|

1 − 0.92 + 0.1δ(k) and

Rsy(k) = /sk ⊥ vk/ = Rsd(k) =

s2, k = 0 0, k = 1.

This gives the filter parameters h0= 0.8478 and h1 = 0.7488.

(b) The resulting minimum mean squared error is given by (see e.q. (7.54) in the book) E{(sk− ˆsk)2} = Rss(0) − h0Rsy(0) − h1Rsy(1) = 1 − 0.8478 = 0.1522.

References

Related documents

characteristics recurrently seen in tumour cells, including existing DDR defects (by exploiting synthetic lethal interactions), replication fork stress, genomic

Menurut al-Baydawi pula, sesiapa sahaja daripada kalangan penganut agama-agama samawi tersebut yang beriman dan beramal sesuai dengan ketentuan ajaran agamanya

Recently, HS has been employed in several structural engineering optimization problems such as cellular beams [27], trusses [28, 29], tuned mass dampers [30]-[32],

This section discussed inferential statistics of t-test analysis on the influence of UBE facilities on classroom control, teachers- students’ classroom interaction,

Purpose: This study was carried out to investigate the effects of two doses (150 and 300 mg/kg) of ethanolic extract of strawberry leaves on antioxidant capacity of liver, kidney

The trend of the zooplankton population was noticed in all the stations of the river Kali, especially station 6 was found to have highest diversity of zooplanktons as it is a

Based on the results of research regarding professional teachers in the integration of Semangko Faulth and Megatrush Mentawai in the teaching of geography at senior high school

In this study, the Asian Health Coalition and its community partners conducted HBV screenings and follow-up linkage to care in both clinical and non- clinical settings.. The