Deconvolution Experiment for 1-D Filters Use the function firfilt( ) to implement the…
- User
Deconvolution Experiment for 1-D Filters
Use the function firfilt( ) to implement the following FIR filter w[n]=x[n]−0.9x[n-1] on the input signal x[n] defined via the MATLAB statement: xx = 256*(rem(0:100,50)<10); In MATLAB you must define the vector of filter coefficients bb needed in firfilt. (a) Plot both the input and output waveforms x[n] and w[n] on the same figure, using subplot. Make the discrete-time signal plots with MATLAB’s stem function, but restrict the horizontal axis to the range 0 ≤ n ≤ 75. Explain why the output appears the way it does by figuring out (mathematically) the effect of the filter coefficients in (∗). (b) Note that w[n] and x[n] are not the same length. Determine the length of the filtered signal w[n], and explain how its length is related to the length of x[n] and the length of the FIR filter.
Restoration Filter The following FIR filter (FIR FILTER-2) [math]y[n]=\sum_{l=0}^{M}r^lw[n-l][/math] can be use to undo the effects of the FIR filter in the previous section.t performs restoration, but it only does this approximately. Use the following steps to show how well it works when r = 0.9 and M = 22. (c) Process the signal w[n] from w[n] =x[n] − 0.9x[n-1] with FILTER-2 to obtain the output signal y[n]. (d) Make stem plots of w[n] and y[n] using a time-index axis n that is the same for both signals. Put the stem plots in the same window for comparison—using a two-panel subplot. (e) Since the objective of the restoration filter is to produce a y[n] that is almost identical to x[n], make a plot of the error (difference) between x[n] and y[n] over the range 0 ≤ n < 50.
Worst-Case Error (f) Evaluate the worst-case error by doing the following: use MATLAB’s max() function to find the maximum of the difference between y[n] and x[n] in the range 0 ≤ n < 50. (g) What does the error plot and worst case error tell you about the quality of the restoration of x[n]? How small do you think the worst case error has to be so that it cannot be seen on a plot?
- Assistant
(a) To plot the input and output waveforms x[n] and w[n] on the same figure, we can write the following MATLAB code:
- User
An Echo Filter The following FIR filter can be interpreted as an echo filter. y1[n] = x1[n] + rx1[n-p] () Explain why this is a valid interpretation by working out the following: (a) You have an audio signal sampled at fs = 8000 Hz and you would like to add a delayed version of the signal to simulate an echo. The time delay of the echo should be 0.2 seconds, and the strength of the echo should be 90% percent of the original. Determine the values of r and P in (); make P an integer. (b) Describe the filter coefficients of this FIR filter, and determine its length. (c) Implement the echo filter in (**) with the values of r and P determined in part (a). Use the speech signal in the vector x2 found in the file labdat.mat. Listen to the result to verify that you have produced an audible echo.
- Assistant
(a) To determine the values of r and P for the echo filter, we start by setting the time delay of the echo to 0.2 seconds, and the strength of the echo to 90%:
time_delay = 0.2; % seconds fs = 8000; % Hz r = 0.9;
Now we can calculate the value for P:
P = round(time_delay * fs); % Make P an integer
(b) The filter coefficients for the echo filter are defined by two impulse responses: the first is a direct transmission with a gain of 1 at n=0, and the second is an echo signal with a gain of r at n=P. Therefore, the filter coefficients are given by:
h[n] = {1 if n = 0, r if n = P, 0 otherwise}
The length of the FIR filter is given by the maximum value of n for a nonzero coefficient, which in this case is:
length = P + 1
(c) To implement the echo filter with the values of r and P determined in part (a), we can use the following MATLAB code:
MATLAB% Load speech signal load labdat.mat; % Apply echo filter bb_echo = zeros(1, P+1); bb_echo(1) = 1; bb_echo(P+1) = r; y1 = firfilt(bb_echo, x2); % Normalize and listen to the result y1 = y1 / max(abs(y1)); soundsc(y1, fs); - User
- Assistant