DSP - Manual Part
DSP - Manual Part
Experiment No. 3
Aim: Write a program to perform circular and linear convolution on two sequences and
interpret your results.
Code:
Figures obtained :
Experiment No. 4
Theory: Triangular wave is not a sinusoidal function. A triangular wave can be represented
using a linear combination of sinusoidal functions (sine and cosine functions). A periodical
function can be represented in this way using Fourier series representation.
From frequency point of view it can be shown that the sine wave contains only a single
frequency (its fundamental frequency). A frequency spectrum of triangular wave will contain a
large number of frequencies (fundamental as well as its harmonics).
So in short a triangular function is a periodically varying function but not a sinusoidal function,
but it can be represented as a linear combination of sinusoidal function of varying frequencies.
In 1807, Joseph Fourier proposed that a completely arbitrary periodic function f(t)
could be expressed as a series of the form
Code:
Figures obtained :
Experiment No. 5
Aim: To find DFT of any given sequence and also plot its magnitude and phase response.
Theory: The discrete Fourier transform (DFT) X[k] of a finite-length sequence x[n] can be easily
computed in MATLAB using the function fft. There are two versions of this function. fft(x)
computes the DFT X[k] of the sequence x[n] where the length of X[k] is the same as that of x[n].
fft(x,L) computes the L-point DFT of a sequence x[n] of length N where L ≥ N. IfL > N, x[n] is
zero-padded with L−N trailing zero-valued samples before the DFT is computed. The inverse
discrete Fourier transform (IDFT) x[n] of a DFT sequence X[k] can likewise be computed using
the function ifft, which also has two versions.
If {h[n]} denotes the impulse response sequence of an LTI discrete-time system, its frequency
response H(ejω) is given by the discrete-time Fourier transform of {h[n]}, that is,
In general (ejω) is a complex function of ω with a period 2π and can be expressed in terms of its
real and imaginary parts or its magnitude and phase. Thus,
Where Hre(ejω) and Him(ejω) are, respectively, the real and imaginary parts of H(ejω), and
The quantity |H(ejω)| is called the magnitude response and the quantity θ(ω) is called the phase
response of the LTI discrete-time system.
Code:
Figure Obtained:
(e) If we find N-point DFT of sequence of length L such that N<L , then what will be the
result?
(f) If we find N-point DFT of sequence of length L such that N=L , then what will be the
result?
(g) What is impulse response of a system?
(h) What is an LTI system?
Experiment No. 6
Aim: To design a low pass, high pass, band pass, band stop filter using different window
functions (a) Rectangular (b) Hamming (c) Hanning (4) Blackman (5) Bartlett , and plot
their magnitude and phase response.
Theory:
Conceptually the simplest approach to FIR filter design is to simply truncate to a finite number
of terms the doubly infinite-length impulse response coefficients obtained by computing the
inverse discrete-time Fourier transform of the desired ideal frequency response.
However, a simple truncation results in an oscillatory behavior in the respective magnitude
response of the FIR filter, which is more commonly referred to as the Gibbs phenomenon. The
Gibbs phenomenon can be reduced by windowing the doubly infinite-length impulse response
coefficients by an appropriate finite-length window function. The functions fir1 and fir2 can be
employed to design windowed FIR digital filters in MATLAB. Both functions yield a linear-
phase design.
The function fir1 can be used to design conventional lowpass, highpass, bandpass, and bandstop
linear-phase FIR filters. The command b = fir1(N,Wn)
returns in vector b the impulse response coefficients, arranged in ascending powers of z−1, of a
lowpass or a bandpass filter of order N for an assumed sampling frequency of 2 Hz. For lowpass
design, the normalized cutoff frequency is specified by a scalar W n, a number between 0 and 1.
For bandpass design, Wn is a two-element vector [Wn1, Wn2] containing the specified passband
edges where0 < Wn1 < Wn2 < 1. The command
b = fir1(N,Wn,’high’)
with N an even integer, is used for designing a highpass filter. The command
b = fir1(N,Wn,’stop’)
with Wn a two-element vector, is employed for designing a bandstop FIR filter. If none is
specified, the Hamming window is employed as a default. The command
b = fir1(N, Wn, taper)
makes use of the specified window coefficients of length N+1 in the vector taper. However, the
window coefficients must be generated a priori using an appropriate MATLAB function such as
blackman, hamming, hanning, chebwin, or kaiser. The commands to use are of the following
forms:
taper = blackman(N) taper = hamming(N) taper = hanning(N)
taper = chebwin(N) taper = kaiser(N, beta)
The function fir2 can be used to design linear-phase FIR filters with arbitrarily shaped magnitude
responses. In its basic form, the command is
b = fir2(N, fpts, mval)
which returns in the vector b of length N+1 the impulse response coefficients, arranged in
ascending powers of z−1. fpts is the vector of specified frequency points, arranged in an
increasing order, in the range 0 to 1 with the first frequency point being 0 and the last frequency
point being 1. As before, the sampling frequency is assumed to be 2 Hz. mval is a vector of
specified magnitude values at the specified frequency points and therefore must
also be of the same length as fpts. The Hamming window is used as a default. To make use of
other windows, the command to use is
b = fir2(N, fpts, mval,taper)
where the vector taper contains the specified window coefficients.
Code:
Figures: