4.15  Extra Exercises

f
4.1.
Taking Figure 1.10 as a reference, decode the DTMF symbols of Figure 4.47, which correspond to a phone number with eight digits.
PIC
Figure 4.47: Eight DTMF symbols, each one with a 100 ms duration.
f
4.2.
Can a discrete-time random process X[n] have infinite power? If yes, under what conditions? Can these conditions be achieved in practice?
f
4.3.
Modify Listing 4.34 to investigate how the sidelobes are decreased in the DTFT of the Hann window by combining three DTFTs of a rectangular window. Then, perform the same analysis for the Hamming window.
Listing 4.34: MatlabOctaveCodeSnippets/snip_frequency_testHannDTFT.m
1function snip_frequency_testHannDTFT 
2N=9; %number of window samples 
3[dtftHann,w]=freqz(hann(N)); %get values of the DTFT as reference 
4dtftHann2=0.5*rectWinDTFT(w,N)- 0.25*rectWinDTFT(w+(2*pi/(N-1)),N)... 
5    -0.25*rectWinDTFT(w-(2*pi/(N-1)),N); %DTFT using expression 
6plot(w,real(dtftHann-dtftHann2),w,imag(dtftHann-dtftHann2)) %error 
7end 
8function D=rectWinDTFT(w,N) %get DTFT of rectangular window 
9D=sin(0.5*N*w)./sin(0.5*w).*exp(-j*0.5*w*(N-1)); 
10end
f
4.4.
Explore the computation and relationships among convolution, correlation and FFT. Assume a vector x=[0 1 4 8 0] with M = 5 elements. a) Explain why in Matlab, conv(x,x), the convolution of x with x itself results into a vector with 2M 1 elements. b) Compare the equation of a convolution x[n]h[n] y[n] = k=h[k]x[k n]

with the equation of an autocorrelation

R[] = k=x[k]x[k + ].

Then, prove that x[n]x[n]=R[n] and confirm it in Matlab observing that conv(x,fliplr(x)) and xcorr(x) lead to (approximately) the same result in Matlab. Plot conv(x,x) and xcorr(x). c) The results differ in b) mainly because xcorr uses a FFT to compute the correlation. Try to explain how the following code is used to compute the autocorrelation

    % Autocorrelation
    % Compute correlation via FFT
    X = fft(x,2^nextpow2(2*M-1));
    c = ifft(abs(X).^2);

You may want to use type xcorr and take a look at the source code to see how the vector c above is modified to give the expected result (i.e., there is a postprocessing step after the two lines above).

f
4.5.
Short-time energy. Use the same procedure as before to record the sentence “We were away” or similar. Calculate the speech energy e for each frame of t milliseconds (ms), without overlap among frames. Use t {10,30,100,200} ms to get four energy trajectories. Estimate the first-derivative of e using Δen = en en1. Estimate the second-derivative using ΔΔen = Δen Δen1. Use subplot to show simultaneously the waveform (subplot(411)) , e (subplot(412)), Δe (subplot(413)) and ΔΔe (subplot(414)). Do that for each t and choose the value of t that leads to the best plots in terms of distinguishing when it is silence or speech.
f
4.6.
Use a function such as specgram to plot both the wide and narrowband spectrograms of the sentence recorded in the previous exercise. In both cases, a) what were the window lengths and equivalent bandwidths you used? b) What were the complete commands?
f
4.7.
Linear regression. Assume there are N points (x,y), where x and y . Find the parameters a and b of a first order polynomial y~ = ax + b that best fits the data in terms of the minimum total squared error E = n=1N(yn y~n)2. However, try to write the two final equations using correlations (for example, the autocorrelation Rx(0) = n=1Nxn2 at lag m = 0 is one possible term). Use your equations to fit a line to the following training data: x=rand(1,100); y=3*x+4+0.5*randn(1,100); plot(x,y,’x’) and plot the line superimposed to the training data.
f
4.8.
Linear predictive coding. Assume the example in Application 4.4, where the LPC filter has order P = 3 and the signal is x[n] = [10,8,3,2,4,2,1,2]. Assuming the autocorrelation method, prove that the coefficients ai of the prediction filter y~[n] = a1x[n 1] + a2x[n 2] + a3x[n 3] can be found by solving the matrix equation [ R[0] R[1] R[2] R[1] R[0] R[1] R[2] R[1] R[0] ] [ a1 a2 a3 ] = [ R[1] R[2] R[3] ]

where R[] is the correlation at lag .