Upload
miindsurfer
View
50
Download
2
Embed Size (px)
DESCRIPTION
dsp
Citation preview
FACULTY OF ENGINEERINGMULTIMEDIA UNIVERSITY
ASSIGNMENT
ETM4096
DIGITAL SIGNAL PROCESSING
TRIMESTER 3 (2007/2008)
QUESTION 1
Part (a)(i)
Triangular window
Syntax:
triang(L)
Description:
triang(L) returns an L-point triangular window in the column vector w. The coefficients of a
triangular window are:
For L odd:
For L even:
The triangular window is very similar to a Bartlett window. The Bartlett window always ends
with zeros at samples 1 and L, while the triangular window is nonzero at those points. For L odd,
the center L-2 points of triang(L-2) are equivalent to bartlett(L)
Tukey window
Syntax :
w = tukeywin(L,r)
Description:
w = tukeywin(L,r) returns an L-point, Tukey window in column vector w. Tukey
windows are cosine-tapered windows. r is the ratio of taper to constant sections and is between 0
and 1. is a rectwin window and is a hann window. The default value for r is 0.5.
The equation for computing the coefficients of a Tukey window is
The window length is .
Gaussian window
Syntax :
w = gausswin(L)w = gausswin(L,α)
Description:
w = gausswin(L) returns an L-point Gaussian window in the column vector w. L is a
positive integer. The coefficients of a Gaussian window are computed from the following
equation.
where , and the window length is
w = gausswin(L,α) returns an L-point Gaussian window where α is the reciprocal of the
standard deviation. The width of the window is inversely related to the value of α; a larger value
of α produces a more narrow window. If α is omitted, it defaults to 2.5.
Chebyshev window
Syntax:
w = chebwin(L,r)
Description:
w = chebwin(L,r) returns the column vector w containing the length L Chebyshev window
whose Fourier transform sidelobe magnitude is r dB below the mainlobe magnitude. The default
value for r is 100.0 dB.
Bartlett window
Syntax:
w = bartlett(L)
Description:
w = bartlett(L) returns an L-point Bartlett window in the column vector w, where L must
be a positive integer. The coefficients of a Bartlett window are computed as follows:
For L odd
For L even
The window length .
The Bartlett window is very similar to a triangular window as returned by the triang function.
The Bartlett window always ends with zeros at samples 1 and n, however, while the triangular
window is nonzero at those points. For L odd, the center L-2 points of bartlett(L) are
equivalent to triang(L-2).
Bohman window
Syntax:
w = bohmanwin(L)
Description:
w = bohmanwin(L) returns an L-point Bohman window in column vector w. A Bohman
window is the convolution of two half-duration cosine lobes. In the time domain, it is the product
of a triangular window and a single cycle of a cosine with a term added to set the first derivative
to zero at the boundary. Bohman windows fall off as 1/w4.
The equation for computing the coefficients of a Bohman window is
where and the window length is .
Parzen window
Syntax:
w = parzenwin(L)
Description:
w = parzenwin(L) returns the L-point Parzen (de la Valle-Poussin) window in column
vector w. Parzen windows are piecewise cubic approximations of Gaussian windows. Parzen
window sidelobes fall off as .
Blackman-Harris window
Syntax:
w = blackmanharris(L)
Description:
w = blackmanharris(L) returns an L-point, minimum , 4-term Blackman-Harris window
in the column vector w. The window is minimum in the sense that its maximum sidelobes are
minimized.
The equation for computing the coefficients of a minimum 4-term Blackman-harris window is
where and the window length is .
The coefficients for this window are
a0 = 0.35875
a1 = 0.48829
a2 = 0.14128
a3 = 0.01168
Flat top windows
Syntax:
w = flattopwin(L)
w = flattopwin(L,sflag)
Description:
Flat Top windows have very low passband ripple (< 0.01 dB) and are used primarily for
calibration purposes. Their bandwidth is approximately 2.5 times wider than a Hann window.
w = flattopwin(L) returns the L-point symmetric flat top window in column vector w.
w = flattopwin(L,sflag) returns the L-point symmetric flat top window using sflag
window sampling, where sflag is either 'symmetric' or 'periodic'. The
'periodic' flag is useful for DFT/FFT purposes, such as in spectral analysis. The DFT/FFT
contains an implicit periodic extension and the periodic flag enables a signal windowed with a
periodic window to have perfect periodic extension. When 'periodic' is specified,
flattopwin computes a length L+1 window and returns the first L points. When using
windows for filter design, the 'symmetric' flag should be used.
Flat top windows are summations of cosines. The coefficients of a flat top window are computed
from the following equation
where and elsewhere and the window length is L = N +1. The coefficient values
are
a0 = 0.21557895 a1 = 0.41663158 a2 = 0.277263158
a3 = 0.083578947 a4 = 0.006947368
Part (a)(ii)
The difference between the Bartlett and Triangular window is that the Bartlett window always
ends with zeros at samples 1 and n, however, the triangular window is non-zero at those points.
Part (a)(iii)
The sinusoidal windows besides Hanning, Hamming and Blackman windows are:
- Bohman window
- Parzen window
- Flat top window
- Blackman-Harris window
- Bartlett-Hann
- Nutall Blackman Harris window
- Gaussian window
- Kaiser
- Lanczos
- Chebyshev
- Cosine
Part (a)(iv)
Similarities:
Rectangular, Tukey, Gaussian, and Kaiser yield fast roll-off in the frequency domain, but have
limited attenuation in the stop-band along with poor group delay characteristics. We can also see
that these windows have a narrow main lobe and significant ammount of side lobes.
Relation with rectangular window:
If we keep on increasing the width of these windows, the window pattern approaches rectangular window.
Part (b)(i)
Given = = 0.01, = 0.34 , = 0.36
2 f = -
2 f = (0.36 – 0.34)
f = 0.01
= - 20log
= -20log(0.01)
= 40dB
N =
N =
N = 224.
Since is in the range 21 , is defined as;
= 0.5842 + 0.07886( – 21)
= 0.5842 + 0.07886(40 – 21)
= 3.4
To plot the resulting window using the value obtained previously for and N, we write the
MATLAB code as below:
N = 224;
beta = 3.4;
w = Kaiser(N, beta)
plot(w)
Figure 1: Kaiser Window for = 3.4 and N = 224
Part (b)(ii)
MATLAB codes:
N = 224;
beta = 3.4;
n = 0:N-1
bes_1 = abs(besseli(0, beta));
x = beta*sqrt(1-[(n-round(N/2))/(round(N/2))].^2)
bes_2 = besseli(0,x);
w = bes_2./bes_1
length(w)
plot(w,'-r')
xlabel('samples');
ylabel('amplitude');
Figure 2: Kaiser Window obtained from the zeroth-order modified Bessel function of the first kind
Answer for this part agrees with the answer for the previous part
Part (b) (iii)
The desired filter is obtained by using the following code
N = 224;
beta = 3.4;
wc = 0.35;
h = fir1(N, wc,'high', kaiser(N+1, beta))
To plot the impulse response and the frequency response we write the codes
impz(h)
freqz(h)
Figure 3: Impulse response of the filter
Figure 4: Frequency response of the filter
Part ( c)
MATLAB code for designing the filter using Parks-McClellan algorithm:
Rp = 1;
Rs = 40;
fs = 8000;
f = [1500 2000];
a = [1 0];
dev = [(10^(Rp/20)-1)/(10^(Rp/20)+1) 10^(-Rs/20)];
[N,fo,mo,w] = remezord(f, a, dev, fs)
b = remez(N, fo, mo, w);
impz(b);
figure;
[h,f] = freqz(b, 1, 1024, fs);
freqz(b, 1, 1024, fs);
figure;
plot(f, (abs(h))) ;
Figure 5: Impulse response of the filter
Figure 6: Frequency response of the filter
Figure 7: Actual plot of frequency response
QUESTION 2
= 200kHz
First we calculate passband ripple, and stopband ripple,
1 = |20 (1 - )| 22 = |20 ( )|
1 - = =
In order to determine the order of the filter we need calculate discrimination factor, d and selectivity factor, k
d = 0.0405
= = 0.66667
The order, N is given as;
= = 7.909 = 8
The 3dB cutoff frequency, is calculated using
43.53
We set = 43.73kHz = 274776.9794rad/sec
Transforming using impulse invariant method:
MATLAT codes:
N = 8;
wc = 274776.9794;
fs = 200000;
[z, p, k] = buttap(N)
[num, den] = zp2tf(z, p, k)
[numt, dent] = lp2lp(num, den, wc)
[bz, az] = impinvar(numt, dent, fs)
Freqz(bz, az)
Figure 8: Filter obtained by using impulse invariant method
Transforming using bilinear transformation method:
MATLAB code:
N = 8;
wc = 274776.9794;
fs = 200000;
[z, p, k]= buttap(N)
[b, a] = zp2tf(z, p, k)
[num, den] = lp2lp(b, a, wc)
[bz, az] = bilinear(num, den, fs)
freqz(bz, az)
Figure 9: Filter obtained using bilinear transformation method