TX00CQ31 –Digital Signal Processing

Study 6:  Analog Filters and applying DSP tricks


Read these instructions first!

Number

Questions

Write your answer in this column

Hints

Q1

Generate filter parameters for 4’th degree Butterworth, low-pass filter, cutoff frequency 1.5 kHz, and sampling rate 8000 Hz.

Draw the Argand’s diagram.

Commands:

fc = 1500;

fs = 8000;

[b_q1,a_q1] = butter(4, fc/(fs/2));

zplane(b_q1, a_q1);

argand's diagram

butter

 

zplane

Q2

Stem-plot few first values of the impulse response of the system, and verify from the plot that this is indeed an IIR-system.

n = -10:60;

d = n == 0;

y = filter(b_q1, a_q1, d);

stem(n, y);

response

filter

Q3

Generate filter parameters for 4’th degree Elliptic, low-pass filter, cutoff frequency 1.5 kHz, passband ripple 4 dB, attenuation 60 dB and sampling rate 8000 Hz. Compare responces of Q1 and Q3 filters. What are the differencies?

Commands: 

rp = 4;

rs = 60;

[b_q3, a_q3] = ellip(4, rp, rs, fc/(fs/2));

zplane(b_q3, a_q3);

response response

ellip

freqz

Q4

In this task we demonstrate how to clean up a signal from unwanted component. First create a signal of two sinusoidals, one with the frequency of  2p·0,05 rad/sample, and an another with the frequency of 2p·0,47 rad/sample. Create a  moving average filter whose length can be adjusted. Find out the optimal value of filter length which removes the higher frequency, but passes thru the lower frequency.

Commands: 

n = 0:1000;

x1 = cos(2*pi*0.05*n);

x2 = cos(2*pi*0.47*n);

signal = x1 + x2;

filter_lengths = 2:1:50;

filtered_signals = cell(1, length(filter_lengths));

mse_values = zeros(1, length(filter_lengths));

for i = 1:length(filter_lengths) filter_length = filter_lengths(i); filter_coefficients = ones(1, filter_length) / filter_length; filtered_signal = conv(signal, filter_coefficients, 'same'); mse_values(i) = mean((filtered_signal - x1).^2); filtered_signals{i} = filtered_signal; end

[min_mse, optimal_length_index] = min(mse_values);

optimal_filter_length = filter_lengths(optimal_length_index);

optimal_filtered_signal = filtered_signals{optimal_length_index};

Show the signal before and after filtering.

Before:

before

After:

after
What is the optimal length M of the moving average filter.

Optimal length is: 2.

ones

filter