KEMBAR78
Manual | PDF | Discrete Fourier Transform | Sampling (Signal Processing)
0% found this document useful (0 votes)
40 views38 pages

Manual

Uploaded by

Sparsh Srivastav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views38 pages

Manual

Uploaded by

Sparsh Srivastav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Table of Contents

Sr. No Name of Experiment Page Date


1 Write a program to verify the sampling theorem and aliasing effects with
various sampling frequencies.
2 Write a programs to study and verify DFT properties (Minimum two
properties).
3 Write a program to find 4 point circular convolution and compare the
result with 8 point circular convolution to study aliasing effect in time
domain.
4 (a) To find Z and inverse Z transform and pole zero plot of Z-transfer
function. (b) To solve the difference equation and find the system
response using Z transform.
5 To plot the poles and zeros of a transfer function when the coefficients of
the transfer (a) function are given, study stability of different transfer
functions.
6 To study the effect of different windows on FIR filter response. Pass the
filter coefficient designed in experiment 7 via different windows and see
the effect on the filter response.
7 Design Butterworth filter using Bilinear transformation method for LPF
and write a (a) program to draw the frequency response of the filter.
8 To plot the mapping function used in bilinear transformation method of
IIR filter design.

Page 1
Experiment Number: 01
Title: Implement the sampling theorem and aliasing effects by samplingan analog signal with various
sampling frequencies.
Theory:
Sampling: Sampling is the reduction of a continuous-time signal to a discrete-time signal. A common
example is the conversion of a sound wave (a continuous signal) to a sequence of samples (a discrete-
time signal).
It is a process of converting a signal (for example, a function of continuous time or space) into a sequence of
values (a function of discrete time or space).

Signal sampling representation. The continuous signal is represented with a green colored line while
the discrete samples are indicated by the blue vertical lines.

Sampling Theorem: A continuous time signal can be represented in its samples and can be recovered
back when sampling frequency fs is greater than or equal to the twice the highest frequency component
of message signal. i. e.
fs≥2fm.

Page 2
Nyquist Criteria: the Nyquist rate, named after Harry Nyquist, specifies a sampling rate. In units of
samples per second[1] its value is twice the highest frequency (bandwidth) in Hz of a function or signal
to be sampled. With an equal or higher sampling rate, the resulting discrete-time sequence is said to be
free of the distortion known as aliasing.
fs = 2W Where fs the sampling rate W is the highest frequency
Aliasing Effect: The phenomena of high frequency sinusoidal components acquiring the identity of
low frequency sinusoidal components after sampling is called aliasing (i.e., aliasing is higher
frequencies impersonating lower frequencies). The aliasing problem will arise if the sampling rate does
not satisfy the Nyquist sampling criteria.
The overlapped region in case of under sampling represents aliasing effect, whichcan be removed by
 considering fs >2fm
 By using anti-aliasing filters.
Applications:
1. Audio sampling: Digital audio uses pulse-code modulation (PCM) and digital signals for

Page 3
sound reproduction. This includes analog-to-digital conversion (ADC), digital-to-analog conversion
(DAC), storage, and transmission.
2. Video sampling: Standard-definition television (SDTV) uses either 720 by 480 pixels (US
NTSC 525-line) or 720 by 576 pixels (UK PAL 625-line) forthe visible picture area. High (HDTV)
uses 720p (progressive), 1080i (interlaced), and 1080p (progressive, alsoknown as Full-HD).
3. 3D sampling: The process of volume rendering samples a 3D grid
of voxels to produce 3D renderings of sliced (tomographic) data. The 3D grid is assumed to represent a
continuous region of 3D space. Volume rendering is common in medical imaging, X-ray computed
tomography (CT/CAT), magnetic resonance imaging (MRI), positron emission tomography (PET) are
some examples. It is also used for seismictomography and other applications.

Page 4
Experiment Number: 02
Title: To study the properties of DFT. Write programs to confirm all DFT properties.
Theory:
The DFT of a discrete-time signal x(n) is a finite duration discrete frequency sequence. The DFT of a
discrete-time sequence designated by X(k) is defined as:

The importance of DFT is it plays an important role in the analysis, the design, andthe implementation
of DSP algorithms and systems
Properties of Discrete Fourier Transform(DFT):
1. Periodicity
2. Linearity
3. Circular Symmetries of a sequence
4. Symmetry Property of a sequence
5. Circular Convolution
6. Multiplication
7. Time reversal of a sequence 8. Circular Time shift
8. Circular frequency shift
9. Complex conjugate property
10. Circular Correlation
11. Parseval’s Theorem

Page 5
PARSEVAL’S THEOREM says that the DFT is an energy-conserving transformation and allows us to find
the signal energy either from the signal or itsspectrum. This implies that the sum of squares of the signal
samples is related tothe sum of squares of the magnitude of the DFT samples.

If DFT {x1(n)} = X1(k)


And DFT {x2(n)} = X2(k)

then

Parsevals Relation of DFT

CIRCULAR TIME SHIFTING PROPERTY OF DFT ( DFT of delayed sequence)


Theory:
Let x(n) be a discrete sequence and x|(n) be a delayed or shifted sequence of x(n) by n0 units of time.

Proof:
By the definition of IDFT,

Page 6
Applications of DFT:
Two important applications of DFT are:
1. It allows us to determine the frequency content of a signal, that is, to performspectral analysis.
2. It is used to perform filtering operation in the frequency domain.
3. The DFT is used for spectral analysis of signals using a digital computer.
4. The DFT is used to perform filtering operations on signals using digitalcomputer.

Page 7
Experiment Number: 03
Title: To study the circular convolution for calculation of linear convolution and aliasing effect. Take two
sequences of length 4. Write a program to find 4 point circular convolution and compare the result
with 8 point circular convolution to study aliasing in time domain.
Theory:
Periodic or Circular Convolution:
The regular (or linear) convolution of two signals, both of which are periodic, does not exist. For this reason
we resort to periodic convolution by using averages. If both xp(n) and hp(n) are periodic with identical
period N, their periodic convolution generates a convolution result yp(n) that is also periodic with the
same period N. The periodic convolution or circular convolution or cyclic convolution yp(n) of xp(n)
and hp(n) is denoted as yp(n) = xp(n) convolution hp(n).
Over one period (n = 0, 1, ........................... , N–1), it is defined as

Methods of performing Circular Convolution:


The circular convolution of two sequences requires that atleast one of the two sequences should be
periodic. If both the sequences are non-periodic,then periodically extend one of the sequences and then
perform circular convolution.
The circular convolution can be performed only if both the sequences consists of the same number of
samples. If the sequences have different number of samples, then convert the smaller size sequence to
the size of larger size sequence by appending zeros. The circular convolution produces a sequence
whose length is same as that of input sequences.
The difference between the two is that in circular convolution the folding and shifting (rotating)
operations are performed in a circular fashion by computing the index of one of the sequences by
modulo-N operation. Inlinear convolution there is no modulo-N operation.
Methods of finding circular convolution:
1. Concentric circle method (Graphical method)
2. Tabular array method
3. Matrices method
4. DFT method
LINEAR CONVOLUTION FROM PERIODIC (CIRCULAR)CONVOLUTION:
The linear convolution of x(n) (with length N1) and h(n) (with length N2) may also be found using the periodic
convolution. Since the linear convolution of x(n) and h(n) yields a sequence of length N1 + N2 – 1,
convert the sequences x(n) and h(n) to length N1 + N2 – 1 by padding with zeros and then perform
circular convolution. The regular convolution of the original unpadded sequences equals the periodic
convolution of the zero-padded sequences.
BASIC DIFFERENCE BETWEEN LINEAR AND CIRCULARCONVOLUTION:
The linear convolution and circular convolution basically involve the same four steps, namely folding one

Page 8
sequence, shifting the folded sequence, multiplying the two sequences and finally summing the value
of the product sequences. The difference between the two is that in circular convolution, the folding
and shifting(rotating) operations are performed in a circular fashion by computing the index ofone of the
sequences by modulo-N operation. In linear convolution, there is no modulo-N operation.

Applications:
1. Circular convolution plays an important role in maximizing the efficiency of a certain kind of common
filtering operation.
2. Circular convolution is used to convolve two discrete Fourier transform(DFT) sequences.

Page 9
Experiment Number: 04
Title:
1. To find Z and inverse Z transform and pole zero plot of Z-transfer function.
2. To solve the difference equation and find the system response using Ztransform.
Theory:
Z-Transform:
 The Z-transform plays an important role in the analysis and representation ofdiscrete-time Linear Shift
Invariant (LSI) systems. It is the generalization of the Discrete-Time Fourier Transform (DTFT).
 The Z-transform has the advantage that it is a simple and systematic method and the complete solution
can be obtained in one step and the initial conditions can be introduced in the beginning of the process
itself.
 To solve the difference equations which are in time domain, they are converted first into algebraic
equations in z-domain using Z-transform, the algebraic equations are manipulated in zdomain and the
result obtained is converted back into time domain using inverse Ztransform
 The Z-transform may be one-sided (unilateral) or two-sided (bilateral). It is the one-sided or unilateral
Z-transform that is more useful, because we mostly deal with causal sequence.

1. The bilateral or two-sided Z-transform of a discrete-time signal or asequence x(n) is defined as:
where z is a complex variable

2. The one-sided or unilateral Z-transform is defined as:

Advantages of Z-Transform:

1. The Z-transform converts the difference equations of a discrete-time system into linear algebraic
equations so that the analysis becomes easy and simple.
2. Convolution in time domain is converted into multiplication in z-domain.
3. Z-transform exists for most of the signals for which Discrete-Time Fourier Transform (DTFT) does
not exist. 4. Also since the Fourier transform is nothing but the Z-transform evaluated along the unit
circle in the z-plane, thefrequency response can be determined.

Page 10
Properties of Z-Transform:

Applications:
In mathematics and signal processing, the z-transform converts a discrete time signal, which is a sequence of
real or complex numbers into a complex frequencydomain representation.

Page 11
Experiment Number: 05
Title: To plot the poles and zeros of a transfer function when the coefficients of the transfer function are given,
study stability of different transfer functions.
Applications:
1. Poles and Zeros of a transfer function are the frequencies for which the value of the denominator and
numerator of transfer function becomes zero respectively.
2. The values of the poles and the zeros of a system determine whether the system is table, and how well
the system performs.

Page 12
Experiment Number: 06
Title: To study the effect of different windows on FIR filter response. Pass the filter coefficients designed in
experiment 6 via different windows and see the effect on the filter response.
Theory:
In signal processing, a finite impulse response (FIR) filter is a filter whose impulse response (or response to
any finite length input) is of finite duration, because it settles to zero in finite time. This is in contrast to
infinite impulse response (IIR) filters, which may have internal feedback and may continue to respond
indefinitely (usually decaying).
Properties
An FIR filter has a number of useful properties which sometimes make it preferable to an infinite impulse
response (IIR) filter.
FIR filters:
Require no feedback. This means that any rounding errors are not compounded by summed iterations.
The same relative error occurs in each calculation. This also makes implementation simpler.
Are inherently stable, since the output is a sum of a finite number of finite multiples of the input
values, so can be no greater than summation times thelargest value appearing in the input.
Can easily be designed to be linear phase by making the coefficient sequence symmetric. This property
is sometimes desired for phase-sensitive applications, for example data communications, seismology,
crossover filters, and mastering.
The advantages of FIR filters are as follows:
FIR filters have exact linear phase.
FIR filters can be realized in both recursive and non-recursive structures.
FIR filters realized non-recursively are always stable
The round off noise can be made small in non-recursive realization.
Disadvantages of FIR filters are as follows:
For the same filter specifications, the order of the filter to be designed ismuch higher than that of IIR.
Large storage requirements and powerful computational facilities required.
The non-integral delay can lead to problems in some signal processingapplications.
Response of FIR filter using RECTANGULAR WINDOW
Response of low pass fir filter using BLACKMAN WINDOW
Response of band stop fir filter using HAMMING WINDOW
Response of low pass fir filter using HAMMING WINDOW
Response of band pass fir filter using KAISER WINDOW
Applications:
FIR filters are often used in Digital Communications in the IF stages of the receiver. For example, a digital
radio receives and down converts the analog signal to the IF frequency and then converts it to digital
with a D/A, then uses the FIR filter to select the desired frequency.

Page 13
Experiment Number:07
Title: Design Butterworth filter using Bilinear transformation method for LPF and write a program to draw the
frequency response of the filter.
Theory:
The bilinear transformation is a conformal mapping that transforms the s- plane to z-plane. In this
mapping, the imaginary axis of s-plane is mapped into the unit circle in z-plane, the left half of s-plane
is mapped into interior of unit circle in z-plane, and the right half of the s-plane is mapped into exterior
of unit circle in z-plane.
The bilinear mapping is a one-to-one mapping and it is accomplished when

This transformation is a one-to-one mapping from the s-domain to the z-domain.


That is, the bilinear transformation is a conformal mapping that transforms the imaginary axis of s-plane
into the unit circle in the z-plane only once, thus avoiding aliasing of frequency components.
Advantages of Bilinear Transformation Method:
The bilinear transformation is one-to-one mapping.
There is no aliasing and so the analog filter need not have a band limitedfrequency response.
The effect of warping on amplitude response can be eliminated by prewarping the analog filter.
The bilinear transformation can be used to design digital filters withprescribed magnitude response with
piecewise constant values.
Disadvantages of Bilinear Transformation Method :
The nonlinear relationship between analog and digital frequencies introduces frequency distortion which
is called frequency warping.
Using the bilinear transformation, a linear phase analog filter cannot be transformed to a linear phase
digital filter.
Applications:
The bilinear transform (also known as Tustin's method) is used in digital signal processing and discrete-
time control theory to transform continuous-time system representations to discrete-time and vice
versa.

Page 14
Experiment Number:08
Title: To plot the mapping function used in bilinear transformation method of IIR filter design. (assignment
may be given)
Theory:
An IIR system is one which is designed by selecting all the infinite samples ofimpulse response
Features of IIR Filters:
The physically realizable IIR filters do not have linear phase. 2.
The IIR filter specifications include the desired characteristics for themagnitude response only.
Design of IIR Filter by the Bilinear Transformation Method:
Approximation of derivatives method and (b) Impulse invariant transformation method. However the
IIR filter design using these methods isappropriate only for the design of low-pass filters and band pass
filters whose resonant frequencies are small. These techniques are not suitable for high-pass or band
reject filters.
The limitation is overcome in the mapping technique called the bilinear transformation. This
transformation is a one-to-one mapping from the s-domain to the z-domain.

Page 15
Experiment Number: 09
Title: Effect of coefficient quantization on the impulse response of the filter usingdirect form I and II
realization and cascade realization.(theory assignment)
Theory:
The different types of structures for realizing IIR systems are:
1. Direct form-I structure
2. Direct form-II structure
3. Transposed form structure
4. Cascade form structure
5. Parallel form structure
6. Lattice structure
7. Ladder structure
Direct form-I structure:
Direct form-I realization of an IIR system is nothing, but the direct implementation of the difference equation
or transfer function. It is the simplest and most straight forward realization structure available. The
direct form structure provides a direct relation between time domain and z-domain equations.
Limitations of direct form-1 structure:
Since the number of delay elements used in direct form-I is more than (double) the order of the
difference equation, it is not effective.
It lacks hardware flexibility.
There are chances of instability due to the quantization noise.
Direct form - II structure:
The Direct form-II structure is an alternative to direct form-I structure. It is more advantageous to use direct
form-II technique than direct form-I, because it uses less number of delay elements than the direct
form-I structure.
Limitations of direct form- II structure:
It also lacks hardware flexibility
There are chances of instability due to the quantization noise
Advantage of direct form- II structure over the direct form-1 structure

 The number of delay elements used in direct form-II is less than that of direct form-I. Cascade Form
Realization: The cascade form structure is nothing, but a cascaded or series interconnection of the sub
transfer functions or sub system functions which are realized by using the direct form structures (either
direct form-I or direct form-II or a combination of both).
The difficulties in cascade structure are:
1. Decision of pairing poles and zeros.
2. Deciding the order of cascading the first and second order sections.
3. Scaling multipliers should be provided between individual sections to preventthe filter variables from
becoming too large or too small.
Comparison:

Page 16
Page 17
Experiment Number: 10
Title: Computation of DCT and IDCT of a discrete time signal and comment onenergy compaction density.
Theory:
Discrete Cosine Transform
The discrete cosine transform (DCT) is closely related to the discrete Fourier transform (DFT). The DFT is
actually one step in the computation of the DCT for a sequence. The DCT, however, has better energy
compaction than the DFT, with just a few of the transform coefficients representing the majority of the
energy in the sequence. This property of the DCT makes it useful in applications such as data
communications and signal coding.
Applications:
 The DCT is the most widely used transformation technique in signal processing, and by far the most
widely used linear transform in data compression. DCT data compression has been fundamental to the
DigitalRevolution.
 Audio signal processing — audio coding, audio data compression ( lossy and lossless), surround sound,
acoustic echo and feedback cancellation, phoneme recognition, time-domain aliasing cancellation
(TDAC)
 Digital radio — Digital Audio Broadcasting (DAB+),HD Radio
 Speech processing — speech coding speech recognition, voice activitydetection (VAD)
 Digital telephony — voice-over-IP (VoIP), mobile telephony, video telephony, teleconferencing,
videoconferencing
 Biometrics — fingerprint orientation, facial recognition systems, biometric watermarking, fingerprint-
based biometric watermarking, palmprint identification/recognition
 Face detection — facial recognition
 Computers and the Internet — the World Wide Web, socialmedia,[44][45] Internet video[54]
 Network bandwidth usage reduction

Page 18
Sampling Theorem using stem
clc;
clear all;
close all;
fm=0.25;
t=-10:0.1:10;
#construction of orignal signal
a=5*sin(2*pi*fm*t);
subplot(4,1,1);
plot(t,a);
xlabel('time');
ylabel('amplitude');
title('orignal signal');
#sampling when fs is greater than fm
fs=10*fm;
n=-50:50;
a_n=5*sin(2*pi*fm*n/fs);
subplot(4,1,2);
stem(n,a_n);
xlabel('time');
ylabel('amplitude');
title('discrete time signal with fs>2fm');
#sampling when fs is less than fm
fs=0.2*fm;
n=-40:40;
a_m=5*sin(2*pi*fm*n/fs);
subplot(4,1,3);
stem(n,a_m);
xlabel('time');
ylabel('amplitude');
title('discrete time signal with fs<2fm');
#sampling when fs is equal to fm
fs=0.25*fm;
n=-40:40;
a_p=5*sin(2*pi*fm*n/fs);
subplot(4,1,4);
stem(n,a_p);
xlabel('time');
ylabel('amplitude');
title('discrete time signal with fs=2fm');
Sampling Theorem using plot
clc;
clear all;
close all;
fm=0.25;
t=-10:0.1:10;
#construction of orignal signal
a=5*sin(2*pi*fm*t);
subplot(4,1,1);
plot(t,a);
xlabel('time');
ylabel('amplitude');
title('orignal signal');
#sampling when fs is greater than fm
fs=10*fm;
t=-10:10;
a_n=5*sin(2*pi*fm*t/fs);
subplot(4,1,2);
plot(t,a_n);
xlabel('time');
ylabel('amplitude');
title('discrete time signal with fs>2fm');
#sampling when fs is less than fm
fs=0.2*fm;
t=-10:10;
a_m=5*sin(2*pi*fm*t/fs);
subplot(4,1,3);
plot(t,a_m);
xlabel('time');
ylabel('amplitude');
title('discrete time signal with fs<2fm');
#sampling when fs is equal to fm
fs=0.25*fm;
t=-10:10;
a_p=5*sin(2*pi*fm*t/fs);
subplot(4,1,4);
plot(t,a_p);
xlabel('time');
ylabel('amplitude');
title('discrete time signal with fs=2fm');
Aliasing:

clear all;
close all;
clc;
t=-10:0.01:10;
T=4;fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x,'linewidth',3);
xlabel('time');
ylabel('amplitude');
grid;
title('input signal');
n1=-4:1:4;
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1,'linewidth',3);
xlabel('number of samples');
ylabel('amplitude');
hold on;
subplot(2,2,2);
plot(n1,x1,'linewidth',3);
xlabel('time');
ylabel('amplitude');
grid;
title('under sampling');
n2=-5:1:5;
x2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);
stem(n2,x2,'linewidth',3);
xlabel('number of samples');
ylabel('amplitude');
hold on;
subplot(2,2,3);
plot(n2,x2,'linewidth',3);
xlabel('time');
ylabel('amplitude');
grid;
title('uniform sampling');
n3=-20:1:20;
x3=cos(2*pi*fm/fs3*n3);
subplot(2,2,4);
stem(n3,x3,'linewidth',3);
hold on;
subplot(2,2,4);
plot(n3,x3,'linewidth',3);
xlabel('number of samples');
ylabel('amplitude');
xlabel('time');
ylabel('amplitude');
grid;
title('over sampling');
Fourier Transform using Matlab
xn=1:4;
[N]=length(xn);
xn=xn.';
n=0:N-1;
for k=0:N-1,
xk(k+1)=exp(-j*2*pi*k*n/N)*xn;
end
disp('x(k)=');
disp(xk)

x(k)=
Columns 1 through 3:
10.0000 + 0i -2.0000 + 2.0000i -2.0000 - 0.0000i

Column 4:
-2.0000 - 2.0000i

• Properties of Fourier Transform


1. Linearity
clc;
clear all;
close all;
x1=[1,2,3,4];
x2=[2,1,2,1];
X1=fft(x1);
X2=fft(x2);
a1=2;
a2=3;
x=a1*x1+a2*x2;
x=fft(x);
X=a1*X1+a2*X2;
disp(x);
disp(X);

Output:
38 + 0i -4 + 4i 2 + 0i -4 - 4i
38 + 0i -4 + 4i 2 + 0i -4 - 4i
2. Circular shifted Signal
close all;
x=[0 2 4 6 8 10 12 14 16];
N=length(x)-1;
n=0:N;
subplot(3,2,1);
stem(n,x);
title('original signal');

#circular shifted
y=circshift(x,[0 5]);
subplot(3,2,2);
stem(n,y);
title('circular shifted signal');

#fourier
x1=fft(x);
y1=fft(y);
subplot(3,2,3);
stem(n,angle(x1));
subplot(3,2,4);
stem(n,angle(y1));
subplot(3,2,5);
stem(n,abs(x1));
subplot(3,2,3);
stem(n,abs(y1));
3. Parseval’s Property
x=[1 2 3 4];
N=length(x);
X=fft(x);
LHS=sum(abs(x.*x));
disp(LHS);
RHS=sum(abs(X.*X))/N;
disp(RHS);

Output:
parrr
30

30
4-point circular convolution
close all;
x=[1 2 3 4];
h=[1 1 1 1];
Nx=length(x);
Nh=length(h);
N=max(Nx, Nh);
yc=cconv(x,h,N);
y=conv(x,h);
n=0:1:Nx-1;
subplot(2,2,1);
stem(n,x);
xlabel('n');
ylabel('x(n');
title('Input seq');

n=0:1:Nh-1;
subplot(2,2,2);
stem(n,h);
xlabel('n');
ylabel('h(n');
title('Impulse seq');

n=0:1:N-1;
subplot(2,2,3);
stem(n,yc);
xlabel('n');
ylabel('yc(n');
title('circular seq');
n=0:1:Nx+Nh-2;
subplot(2,2,4);
stem(n,y);
xlabel('n');
ylabel('y(n)');
title('linear seq');
Experiment Number: 04
#mycode
Clc;
Close all;
syms n
A=(n+1);
disp('The input Equation');
disp(A);
disp('the z trans is:');
B=ztrans(A);
disp(B);
C=iztrans(B);
disp('inverse of z transform is:');
disp(C);
Experiment Number: 05

#Mycode:

clear all;
clc;
Num = [1 0.81 -0.81]
Den = [1 0 0.45]
[z,p,k] = tf2zp(Num,Den);
zplane(z,p);
EXPERIMENT NO.6
Response of FIR filter using rectangular window
clc;
clear all;
close all;
n=20;
fp=100;
fq=300;
fs=1000;
fn=2*pi*fp/fs;
window=rectwin(n+1);
b=fir1(n,fn,'high',window);
w=0:0.001:pi;
[h,w]=freqz(b,1,w);
a=20*log10(abs(h));
b=angle(h);
subplot(2,1,1);
plot(w/pi,a);
xlabel('Normalized frequency');
ylabel('Gain in db');
title('Magnitude Plot');
subplot(2,1,2);
plot(w/pi,b);
xlabel('Nrmalized frequency');
ylabel('Phase in radian');
title('Phase Responce');

OUTPUT:
Response of low pass filter using BlackmanWindow
clc;
clear all;
close all;
n=20;
fp=100;
fq=300;
fs=1000;
fn=2*fp/fs;
window=blackman(n+1);
b=fir1(n,fn,window);
w=0:0.001:pi;
[h,om]=freqz(b,1,w);
a=20*log10(abs(h));
b=angle(h);
subplot(2,1,1);
plot(w/pi,a);
xlabel('Normalized frequency');
ylabel('Gain in db');
title('Magnitude Plot');
subplot(2,1,2);
plot(w/pi,b);
xlabel('Normalized frequency');
ylabel('Phase in radian');
title('Phase Response');

OUTPUT:
Response of band stop FIR filter using HAMMING Window
clc;
clear all;
close all;
n=20;
fp=100;
fq=300;
fs=1000;
wp=2*fp/fs;
ws=2*fq/fs;
wn=[ wp ws ];
window=hamming(n+1);
b=fir1(n,wn,'stop',window);
w=0:0.001:pi;
[h,om]=freqz(b,1,w);
a=20*log10(abs(h));
b=angle(h);
subplot(2,1,1);
plot(w/pi,a);
xlabel('Normalized frequency');
ylabel('Gain in db');
title('Magnitude Plot');
subplot(2,1,2);
plot(w/pi,b);
xlabel('Normalized frequency');
ylabel('Phase in radian');
title('Phase Response');
OUTPUT:
Response of low pass FIR filter using HANNING Window
clc;
clear all;
close all;
n=20;
fp=100;
fq=300;
fs=1000;
fn=2*fp/fs;
window=hanning(n+1);
b=fir1(n,fn,'high',window);
w=0:0.001:pi;
[h,om]=freqz(b,1,w);
a=20*log10(abs(h));
b=angle(h);
subplot(2,1,1);
plot(w/pi,a);
xlabel('Normalized frequency');
ylabel('Gain in db');
title('Magnitude Plot');
subplot(2,1,2);
plot(w/pi,b);
xlabel('Normalized frequency');
ylabel('Phase in radian');
title('Phase Response');

OUTPUT:
Response of band pass FIR filter using KAISER Window
clc;
close all;
n=20;
fp=100;
fq=300;
fs=20000; %sampling rate
F=[ 3000 4000 6000 8000 ]; %band limits
A=[ 0 1 0 ]; %band type(0='stop',1='pass')
dev=[ 0.0001 10^0.1/20 0.0001 ]; %ripple/attenuation
[m,Wn,beta,typ]=kaiserord(F,A,dev,fs); %window parameter
M=kaiserord(F,A,dev,fs);
b=fir1(M,Wn,typ,kaiser(M+1,beta),'noscale');%fiter design w=0:0.001:pi;
[h,om]=freqz(b,1,w);
a=20*log10(abs(h));
b=angle(h);
subplot(2,1,1);
plot(w/pi,a); xlabel('Normalized frequency');
ylabel('Gain in db');
title('Magnitude Plot');
subplot(2,1,2);
plot(w/pi,b);
xlabel('Normalized frequency');
ylabel('Phase in radian');
title('Phase Response');

OUTPUT:
Experiment Number:07
Design Butterworth filter using Bilinear transformation method for LPF and write a
program to draw the frequency response of the filter.
Code:
clc;
close all;
alphas=30;
alphap=0.5;
fpass=1000;
fstop=1500;
fsam=5000;
wp=2*fpass/fsam;
ws=2*fstop/fsam;
[n,wn]=buttord(wp,ws,alphap,alphas);
[b,a]=butter(n,wn);
[h,w]=freqz(b,a);
subplot(2,1,1);
plot(w/pi,20*log10(abs(h)));
xlabel('normalized frequency');
ylabel('Gain in db');
title('Magnitude Response');
subplot(2,1,2); plot(w/pi,angle(h));
xlabel('normalized frequency');
ylabel('Phase in Radian');
title('Phase Response');
Experiment Number:08

1.To plot the mapping function used in bilinear transformation method of IIRfilter design.
clc;
close all;
fs=1000;
fn=fs/2;
fc=300;
n=5;
[z,p,k]=butter(n,fc/fn);
b=k*poly(z);
a=poly(p);
[h,om]=freqz(b,a,512,fs);
subplot(2,1,1),
plot(om,20*log(abs(h)));
xlabel('normalized frequency');
ylabel('gain in db');
title('magnitude response');
subplot(2,1,2);
plot(om,angle(h));
xlabel('normalized frequency');
ylabel('phase in radians');
title('phase response');

You might also like