Vtu DSP Lab Manual (17ecl57,18ecl57)
Vtu DSP Lab Manual (17ecl57,18ecl57)
BACHOLER OF ENGINEERING
3rd year -5th Sem
2019-2020
Prepared By
Jayanthdwijesh H P
Assistant Professor, Dept. of ECE, BGSIT.
||Jai Sri Gurudev||
VISION
To develop high quality engineers with technical knowledge, skills and ethics in the area of
Electronics and Communication Engineering to meet industrial and societal needs.
MISSION
1. To use Hardware and Software tools to design and develop electronic circuits,
systems and solutions.
2. To collaborate effectively with Electronics and Information Technology industries
through internship, induction, technical seminar, technical project, research,
product design and development, industrial visit, staff training in order to provide
the actual industrial exposure to students and faculties.
PROGRAM OUTCOMES (POs)
At the end of the B.E program, students are expected to have developed the following Outcomes.
1. Engineering Knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problems.
2. Problem analysis: Identify, formulate, research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems
and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal, and
environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data,
and synthesis of the information to provide valid conclusions.
5. Modern Tool Usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.
6. The Engineer and Society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.
7. Environment and Sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of need
for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.
9. Individual and Team Work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give
and receive clear instructions.
11. Project Management and Finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one‘s own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
DSP LAB
B.E., V Semester, ELECTRONICS & COMMUNICATION ENGINEERING
[As per Choice Based Credit System (CBCS) Scheme]
Laboratory Experiments
DSP LAB (ECE Department, BGSIT) Course Outcomes: On the completion of this
laboratory course, the students will be able to:
1. Apply the fundamental DSP concepts of MATLAB to solve DSP problems.
2. Analyze the properties of DFT to perform circular convolution and linear
convolution.
3. Analyze the concepts of Sampling Theorem and correlation of signals.
4. Design IIR and FIR filters for given specifications.
5. Support practically with DSP kit, the design of filters.
S/H Quantizer
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 1
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Advantages of DSP
Applications of DSP
1. Filtering.
2. Speech synthesis in which white noise (all frequency components present to the
same level) is filtered on a selective frequency basis in order to get an audio
signal.
3. Speech compression and expansion for use in radio voice communication.
4. Speech recognition.
5. Signal analysis.
6. Image processing: filtering, edge effects, and enhancement.
7. PCM used in telephone communication.
8. High speed MODEM data communication using pulse modulation systems such
as FSK, QAM etc. MODEM transmits high speed (1200-19200 bits per second)
over a band limited (3-4 KHz) analog telephone wire line.
9. Wave form generation.
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 2
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
INTRODUCTION TO MATLAB
MATLAB is a software package for high-performance language for technical
computing. It integrates computation, visualization, and programming in an easy-to-use
environment where problems and solutions are expressed in familiar mathematical
notation. Typical uses include the following
The name MATLAB stands for MATrix LABoratory. MATLAB was written originally
to provide easy access to matrix software developed by the LINPACK (linear system
package) and EISPACK (Eigen system package) projects.
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 3
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Syntax: plot(X, Y)
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 4
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Description = Length (X) returns the Length of the largest array dimension in X. For
vectors, the Length is simply the number of elements. For arrays with more dimensions,
the Length is max (size(X)). The Length of an empty array is zero.
Description: Xlabel (txt) labels the x-axis of the current axes or chart returned by
the gca command. Reissuing the Xlabel command replaces the old label with the new
label.
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 5
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 6
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Continuous form:
clc;
f=input ('enter the input frequency');
t=0:0.01:1;
y=sin (2*pi*f*t);
disp ('the value of y=')
disp(y)
plot (t,y)
xlabel('time');
ylabel('amplitude');
title('sine wave');
OUTPUT:
Enter the input frequency1
The value of y=
Columns 1 through 8
Columns 9 through 16
Columns 17 through 24
Columns 25 through 32
Columns 33 through 40
Columns 41 through 48
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 7
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Columns 49 through 56
Columns 57 through 64
Columns 65 through 72
Columns 73 through 80
Columns 81 through 88
Columns 89 through 96
Graph:
sine wave
1
0.8
0.6
0.4
0.2
amplitude
-0.2
-0.4
-0.6
-0.8
-1
0 0.2 0.4 0.6 0.8 1
time
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 8
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Discrete form
clc;
f=input('enter the input frequency');
n=0:0.1:1;
y=sin(2*pi*f*n);
disp('the value of y=')
disp(y)
stem (n,y)
xlabel('time');
ylabel('amplitude');
title ('sine wave');
OUTPUT:
Enter the input frequency10
The value of y=
1.0e-14 *
Columns 1 through 8
0 -0.0245 -0.0490 0.2818 -0.0980 -0.1225 -0.1470 -0.1715
Columns 9 through 11
-0.1959 -0.2204 -0.2449
Graph:
-15
x 10 sine wave
4
2
amplitude
-1
-2
-3
0 0.2 0.4 0.6 0.8 1
time
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 9
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
Enter the input frequency1
The value of y=
Columns 1 through 8
Columns 9 through 16
Columns 17 through 24
Columns 25 through 32
Columns 33 through 40
Columns 41 through 48
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 10
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Columns 49 through 56
Columns 57 through 64
Columns 65 through 72
Columns 73 through 80
Columns 81 through 88
Columns 89 through 96
Graph:
cosine wave
1
0.8
0.6
0.4
0.2
amplitude
-0.2
-0.4
-0.6
-0.8
-1
0 0.2 0.4 0.6 0.8 1
time
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 11
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Discrete form
clc;
f=input('enter the input frequency');
n=0:0.01:.1;
y=cos(2*pi*f*n);
disp('the value of y=')
disp(y)
stem(n,y)
xlabel('time');
ylabel('amplitude');
title('cosine wave');
OUTPUT:
Enter the input frequency1
The value of y=
Columns 1 through 8
Columns 9 through 16
Columns 17 through 24
Columns 25 through 32
Columns 33 through 40
Columns 41 through 48
Columns 49 through 56
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 12
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Columns 57 through 64
Columns 65 through 72
Columns 73 through 80
Columns 81 through 88
Columns 89 through 96
Graph:
cosine wave
1
0.8
0.6
0.4
0.2
amplitude
-0.2
-0.4
-0.6
-0.8
-1
0 0.2 0.4 0.6 0.8 1
time
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 13
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
The value of y=
Columns 1 through 8
Columns 9 through 11
Graph:
ramp wave
1
0.9
0.8
0.7
0.6
amplitude
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
time
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 14
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Discrete form
clc;
n=0:0.1:1;
y=n;
disp('the value of y=')
disp(y)
stem(n,y)
xlabel('time');
ylabel('amplitude');
title('ramp wave');
OUTPUT:
The value of y=
Columns 1 through 8
Columns 9 through 11
Graph:
ramp wave
1
0.9
0.8
0.7
0.6
amplitude
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
time
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 15
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OBJECTIVE: To verify sampling theorem for Nyquist rate, under sampling and Over
Sampling condition in both time and frequency domain using MATLAB.
THEORY:
Sample: is a piece of data taken from the whole data which is continuous in the time
domain.
Sampling: Sampling is defined as, “The process of measuring the instantaneous values
of continuous-time signal in a discrete form.”
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.
Nyquist Rate Sampling: The Nyquist rate is the minimum sampling rate required to
avoid aliasing, equal to the highest modulating frequency contained within the signal. In
otherwords, Nyquist rate is equal to two sided bandwidth of the signal (Upper and
lower Sidebands) i.e., fs = 2W.To avoid aliasing, the sampling rate must exceed the
Nyquist rate.
i.e. fs>fN, where fN =2W.
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 16
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
f=input('enter the input frequency=');
t=0:0.001:0.1;
y=cos(2*pi*f*t);
disp('the value of y are=')
disp(y)
subplot(3,1,1)
plot(t,y)
xlabel('time');
ylabel('amplitude');
title('cosine wave');
fs=input('enter the sampling frequency=');
ts=1/fs;
tn=0:ts:0.1;
ys=cos(2*pi*fs*tn);
disp('the value of ys are=')
disp(ys)
subplot(3,1,2)
plot(tn,ys)
xlabel('time');
ylabel('amplitude');
title('continuous wave');
subplot(3,1,3)
stem(tn,ys)
xlabel('time');
ylabel('amplitude');
title('discrete wave');
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 17
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
NYQUIST RATE
Enter the input frequency=100
The value of y are=
Columns 1 through 9
1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090
Columns 10 through 18
0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090
Columns 19 through 27
0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090
Columns 28 through 36
-0.3090 0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000
Columns 37 through 45
-0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090
Columns 46 through 54
-1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090
Columns 55 through 63
-0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090 0.3090
Columns 64 through 72
-0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090
Columns 73 through 81
0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000
Columns 82 through 90
0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090
Columns 91 through 99
1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090
Columns 10 through 18
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 18
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Columns 19 through 27
-0.8090 0.3090 1.0000 0.3090 -0.8090 -0.8090 0.3090 1.0000 0.3090
Columns 28 through 36
-0.8090 -0.8090 0.3090 1.0000 0.3090 -0.8090 -0.8090 0.3090 1.0000
Columns 37 through 45
0.3090 -0.8090 -0.8090 0.3090 1.0000 0.3090 -0.8090 -0.8090 0.3090
Columns 46 through 54
1.0000 0.3090 -0.8090 -0.8090 0.3090 1.0000 0.3090 -0.8090 -0.8090
Columns 55 through 63
0.3090 1.0000 0.3090 -0.8090 -0.8090 0.3090 1.0000 0.3090 -0.8090
Columns 64 through 72
-0.8090 0.3090 1.0000 0.3090 -0.8090 -0.8090 0.3090 1.0000 0.3090
Columns 73 through 81
-0.8090 -0.8090 0.3090 1.0000 0.3090 -0.8090 -0.8090 0.3090 1.0000
Columns 82 through 90
0.3090 -0.8090 -0.8090 0.3090 1.0000 0.3090 -0.8090 -0.8090 0.3090
Columns 91 through 99
1.0000 0.3090 -0.8090 -0.8090 0.3090 1.0000 0.3090 -0.8090 -0.8090
0.3090 1.0000
UNDER SAMPLING
Columns 10 through 18
0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090
Columns 19 through 27
0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090
Columns 28 through 36
-0.3090 0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 19
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Columns 37 through 45
-0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090
Columns 46 through 54
-1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090
Columns 55 through 63
-0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090 0.3090
Columns 64 through 72
-0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090
Columns 73 through 81
0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000
Columns 82 through 90
0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090
Columns 91 through 99
1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090
Columns 1 through 9
Columns 10 through 18
-0.5878 -1.0000 -0.5878 0.3090 0.9511 0.8090 0.0000 -0.8090 -0.9511
Columns 19 through 27
-0.3090 0.5878 1.0000 0.5878 -0.3090 -0.9511 -0.8090 0.0000 0.8090
Columns 28 through 36
0.9511 0.3090 -0.5878 -1.0000 -0.5878 0.3090 0.9511 0.8090 -0.0000
Columns 37 through 45
-0.8090 -0.9511 -0.3090 0.5878 1.0000 0.5878 -0.3090 -0.9511 -0.8090
Columns 46 through 54
-0.0000 0.8090 0.9511 0.3090 -0.5878 -1.0000 -0.5878 0.3090 0.9511
Columns 55 through 63
0.8090 -0.0000 -0.8090 -0.9511 -0.3090 0.5878 1.0000 0.5878 -0.3090
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 20
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Columns 64 through 72
-0.9511 -0.8090 -0.0000 0.8090 0.9511 0.3090 -0.5878 -1.0000 -0.5878
Columns 73 through 81
0.3090 0.9511 0.8090 -0.0000 -0.8090 -0.9511 -0.3090 0.5878 1.0000
Columns 82 through 90
0.5878 -0.3090 -0.9511 -0.8090 -0.0000 0.8090 0.9511 0.3090 -0.5878
Columns 91 through 99
-1.0000 -0.5878 0.3090 0.9511 0.8090 0.0000 -0.8090 -0.9511 -0.3090
Columns 10 through 18
0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090
Columns 19 through 27
0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090
Columns 28 through 36
-0.3090 0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000
Columns 37 through 45
-0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090 -0.8090
Columns 46 through 54
-1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090 0.3090 -0.3090
Columns 55 through 63
-0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090 0.3090
Columns 64 through 72
-0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000 0.8090
Columns 73 through 81
0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090 1.0000
Columns 82 through 90
0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090 0.8090
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 21
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Columns 91 through 99
1.0000 0.8090 0.3090 -0.3090 -0.8090 -1.0000 -0.8090 -0.3090 0.3090
Columns 10 through 18
0.9048 -0.3090 -0.9823 0.0628 0.9980 0.1874 -0.9511 -0.4258 0.8443
Columns 19 through 27
0.6374 -0.6845 -0.8090 0.4818 0.9298 -0.2487 -0.9921 0.0000 0.9921
Columns 28 through 36
0.2487 -0.9298 -0.4818 0.8090 0.6845 -0.6374 -0.8443 0.4258 0.9511
Columns 37 through 45
-0.1874 -0.9980 -0.0628 0.9823 0.3090 -0.9048 -0.5358 0.7705 0.7290
Columns 46 through 54
-0.5878 -0.8763 0.3681 0.9686 -0.1253 -1.0000 -0.1253 0.9686 0.3681
Columns 55 through 63
-0.8763 -0.5878 0.7290 0.7705 -0.5358 -0.9048 0.3090 0.9823 -0.0628
Columns 64 through 72
-0.9980 -0.1874 0.9511 0.4258 -0.8443 -0.6374 0.6845 0.8090 -0.4818
Columns 73 through 81
-0.9298 0.2487 0.9921 -0.0000 -0.9921 -0.2487 0.9298 0.4818 -0.8090
Columns 82 through 90
-0.6845 0.6374 0.8443 -0.4258 -0.9511 0.1874 0.9980 0.0628 -0.9823
Columns 91 through 99
-0.3090 0.9048 0.5358 -0.7705 -0.7290 0.5878 0.8763 -0.3681 -0.9686
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 22
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
NYQUIST RATE
UNDER SAMPLING
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 23
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OVER SAMPLING
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 24
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Linear convolution: is the basic operation to calculate the output for any linear time
invariant system given its input and its impulse response.
Circular convolution: is the same thing but considering that the support of the signal is
periodic (as in a circle, hence the name).
Linear and circular convolutions: are fundamentally different operations. For two
vectors, x and y, the circular convolution is equal to the inverse discrete Fourier
transform (DFT) of the product of the vectors' DFTs. Knowing the conditions under
which linear and circular convolution are equivalent allows you to use the DFT to
efficiently compute linear convolutions.
The linear convolution of an N-point vector, x, and an L-point vector, y, has
length N + L - 1.
For the circular convolution of x and y to be equivalent, you must pad the vectors
with zeros to length at least N + L - 1 before you take the DFT. After you invert the
product of the DFTs, retain only the first N + L - 1 element.
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 25
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
x=input ('enter the input sequence');
h=input ('enter the impulse response');
y=conv(x,h);
disp ('the value of y are=')
disp(y)
n=0: length(y)-1;
stem (n,y)
xlabel('time');
ylabel('amplitude');
title ('linear convolution');
OUTPUT:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 26
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 27
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
x=input('enter the input sequence=');
h=input('enter the impulse response=');
y1=conv(x,h);
disp('the value of y1 are=')
disp(y1)
subplot(2,1,1)
n=0:length(y1)-1;
stem(n,y1)
xlabel('time');
ylabel('amplitude');
title('linear convolution1');
y2=conv(h,x);
disp('the value of y2 are=')
disp(y2)
subplot(2,1,2)
n=0:length(y2)-1;
stem(n,y2)
xlabel('time');
ylabel('amplitude');
title('linear convolution2');
if(y1==y2)
disp('the linear convolution is commutative')
else
disp('the linear convolution is not commutative')
end
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 28
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
1 4 8 8 3
1 4 8 8 3
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 29
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
x=input ('enter the input sequence=');
h1=input ('enter the first impulse response=');
h2=input ('enter the second impulse response=');
y1=h1+h2;
y2=conv(x, y1);
disp ('the value of y2 are=')
disp (y2)
Subplot (2, 1, 1)
n=0: length (y2)-1;
stem (n,y2)
xlabel('time');
ylabel('amplitude');
title('linear convolution1');
y3=conv(x,h1);
y4=conv(x,h2);
y5=y3+y4;
disp('the value of y5 are=')
disp(y5)
subplot(2,1,2)
n=0:length(y5)-1;
stem(n,y5)
xlabel('time');
ylabel('amplitude');
title('linear convolution2');
if(y2==y5)
disp('the linear convolution is distributive')
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 30
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
else
disp('the linear convolution is not distributive')
end
OUTPUT:
Enter the input sequence=[1 2 3]
Enter the first impulse response=[1 2]
Enter the second impulse response=[1 1]
The value of y2 are=
2 7 12 9
The value of y5 are=
2 7 12 9
The linear convolution is distributive
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 31
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 32
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 33
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Syntax: c = cconv(a,b,n)
PROGRAM:
clc;
x=input ('enter the input sequence=');
h=input ('enter the input impulse responce=');
N=max (length(x), length (h));
y=cconv(x,h,N);
disp('the value of y are')
disp(y)
n=0: length(y)-1;
stem (n,y)
xlabel('time');
ylabel('amplitude');
title ('circular convolution');
OUTPUT:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 34
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
circular convolution
20
15
amplitude
10
0
0 0.5 1 1.5 2 2.5 3
time
circular convolution
100
80
60
amplitude
40
20
0
0 0.5 1 1.5 2 2.5 3
time
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 35
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
x=input('enter the input sequence=');
h=input('enter the input impulse responce=');
N=max(length(x),length(h));
y1=cconv(x,h,N);
disp('the value of y1 are')
disp(y1)
subplot(3,1,1)
n=0:length(y1)-1;
stem(n,y1)
xlabel('time');
ylabel('amplitude');
title('circular convolution');
y2=cconv(h,x,N);
disp('the value of y2 are')
disp(y2)
subplot(2,1,2)
n=0:length(y2)-1;
stem(n,y2)
xlabel('time');
ylabel('amplitude');
title('circular convolution');
if(y1==y2)
disp('the circular convolution is commutative')
else
disp('the circular convolution is not commutative')
end
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 36
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
14 12 14 20
Graph:
circular convolution
20
15
amplitude
10
0
0 0.5 1 1.5 2 2.5 3
time
circular convolution
20
15
amplitude
10
0
0 0.5 1 1.5 2 2.5 3
time
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 37
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
x=input('enter the input sequence=');
h1=input('enter the input impulse responce=');
h2=input('enter the second impulse response=');
N1=max(length(h1),length(h2));
y1=cconv(h1,h2,N1);
N2=max(length(x),length(y1));
y2=cconv(x,y1,N2);
disp('the value of y2 are')
disp(y2)
subplot(2,1,1)
n=0:length(y2)-1;
stem(n,y2)
xlabel('time');
ylabel('amplitude');
title('circular convolution');
N3=max(length(x),length(h1));
y3=cconv(x,h1,N3);
N4=max(length(y3),length(h2));
y4=cconv(y3,h2,N4);
disp('the value of y4 are')
disp(y4)
subplot(2,1,2)
n=0:length(y4)-1;
stem(n,y4)
xlabel('time');
ylabel('amplitude');
title('circular convolution');
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 38
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
if(y2==y4)
disp('the circular convolution is associative')
else
disp('the circular convolution is not associative')
end
OUTPUT:
Enter the input sequence=[1 2 3 4]
Enter the input impulse response=[3 2 1]
Enter the second impulse response=[2 2 1 1]
The values of y2 are
94 86 86 94
circular convolution
100
80
60
amplitude
40
20
0
0 0.5 1 1.5 2 2.5 3
time
circular convolution
100
80
60
amplitude
40
20
0
0 0.5 1 1.5 2 2.5 3
time
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 39
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Equation
PROGRAM:
clc;
x=input ('enter the input sequence=');
h1=input ('enter the input impulse responce=');
h2=input ('enter the second impulse response=');
y1=h1+h2;
N1=max (length (x), length (y1));
Y2=cconv(x, y1, N1);
disp('the value of y2 are')
disp(y2)
subplot(2,1,1)
n=0:length(y2)-1;
stem(n,y2)
xlabel('time');
ylabel('amplitude');
title('circular convolution');
N2=max(length(x),length(h1));
y3=cconv(x,h1,N2);
N3=max(length(x),length(h2));
y4=cconv(x,h2,N3);
y5=y3+y4;
disp('the value of y4 are')
disp(y5)
subplot(2,1,2)
n=0:length(y5)-1;
stem(n,y5)
xlabel('time');
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 40
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
ylabel('amplitude');
title('circular convolution');
if(y2==y5)
disp('the circular convolution is distributive')
else
disp('the circular convolution is not distributive')
end
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 41
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
THEORY:
Autocorrelation: also known as serial correlation is the correlation of a signal with a
delayed copy of itself as a function of delay. Informally, it is the similarity between
observations as a function of the time lag between them.
Xcorr: Cross-correlation
Syntax:
c = xcorr(x,y)
c = xcorr(x)
Description:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 42
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
Enter the input sequence[1 2 3 4]
Enter the input sequence[4 3 2 1]
The value of y are
1.0000 4.0000 10.0000 20.0000 25.0000 24.0000 16.0000
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 43
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
PROGRAM:
Clc;
a=input('enter the input sequence');
y=xcorr(a,a);
disp('the value of y are')
disp(y)
n=0:length(y)-1;
stem(n,y)
xlabel('time');
ylabel('amplitude');
title('auto correlation');
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 44
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
Graph:
auto correlation
30
25
20
amplitude
15
10
0
0 1 2 3 4 5 6
time
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 45
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
y = filter (b, a, X) filters the data in vector X with the filter described by numerator
coefficient vector b and denominator coefficient vector a. If a(1) is not equal to 1, filter
normalizes the filter coefficients by a(1). If a(1) equals 0, filter returns an error.
PROGRAM:
Clc
num=input(‘enter the numerator co-efficients=’);
den=input(‘enter the denominator co-efficients=’);
N=input(‘enter the number of samples=’);
Step=ones(1,N)
y=filter(num,den,step);
disp(‘the value of y are=’);
disp(y)
subplot(2,1,1)
n=0:length(step)-1;
stem(n, step)
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘step function’);
subplot(2,1,2)
n=0:length(y)-1;
step(n,y)
xlabel(‘time’);
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 46
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
ylabel(‘amplitude’);
title(‘step response’);
PROGRAM:
Clc
num=input(‘enter the numerator co-efficients=’);
den=input(‘enter the denominator co-efficients=’);
N=input(‘enter the number of samples=’);
Impulse=[ones(1,1), zeros(1,N-1)]
h=filter(num,den,impulse);
disp(‘the value of impulse function are=’)
disp(h)
subplot(2,1,1)
n=0:length(impulse)-1;
stem(n,impulse)
xlabel(‘time’)
ylabel(‘amplitude’)
title(‘impulse function’);
subplot(2,1,2)
n=0:length(h)-1;
stem(n,h)
xlabel(‘time’);
ylabel(‘amplitude’);
title(‘impulse response’);
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 47
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
The Inverse Discrete Fourier Transform (IDFT): The inverse Fourier tranform maps
the signal back from the frequency domain into the time domain. A time domain signal
will usually consist of a set of real values, where each value has an associated time (e.g.,
the signal consists of a time series).
Description: x=fft (x, N) returns the N-point DFT. If the length of x is less than x,N.
Syntax: p=angle(x)
Description: p=angle(x) returns the phase angles in routines for each elements of
complex array X.
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 48
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Syntax: abs(x)
Description: abs(x) returns an array Y such that each element of Y is the absolute of the
corresponding elements of x.
PROGRAM:
clc;
x=input('enter the input sequence=');
N=input('enter the number of dft points=');
X=fft(x,N);
disp('the value of X are=')
disp(X)
m=abs(X)
disp('the value of m are=')
disp(m)
subplot(2,1,1)
n=0:length(m)-1;
stem(n,m)
xlabel('time');
ylabel('amplitude');
title('magnitude');
p=angle(X)
disp('the value of p are')
disp(p)
subplot(2,1,2)
n=0:length(p)-1;
stem(n,p)
xlabel('time');
ylabel('amplitude');
title('phase');
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 49
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
m=
10.0000 2.8284 2.0000 2.8284
The values of m are=
p=
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 50
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
X=input('enter the dft sequence=');
N=input('enter the number of idft points=');
x=ifft(X,N);
disp('the value of x are=')
disp(x)
n=0:length(x)-1;
stem(n,x)
xlabel('time');
ylabel('amplitude');
title('input discrete sequence');
OUTPUT:
Enter the dft sequence=[10 -2+2j -2 -2-2j]
Enter the number of idft points=4
The values of x are=
1 2 3 4
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 51
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
𝑵−𝟏
𝑿(𝑲) = ∑𝒏=𝟎 𝐱(𝐧) 𝒆−𝒋𝟐𝝅𝒌𝒏/𝑵 0≤K≤N-1
PROGRAM:
clc;
x=input('enter the dft sequence=');
N=input('enter the number of dft points=');
X=zeros(1,N);
for k=0:N-1
for n=0:N-1
X(k+1)=X(k+1)+x(n+1)*exp((-i)*2*pi*k*n/N);
end
end
disp('the value of X are=')
disp(X)
M=abs(X)
disp('the value of M are=')
disp(M)
subplot(2,1,1)
n=0:length(M)-1;
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 52
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
stem(n,M)
xlabel('time');
ylabel('amplitude');
title('magnitude');
p=angle(X)
disp('the value of p are=')
disp(p)
subplot(2,1,2)
n=0:length(p)-1;
stem(n,p)
xlabel('time');
ylabel('amplitude');
title('phase');
OUTPUT:
M=
p=
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 53
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 54
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
X=input('enter the dft sequence=');
N=input('enter the idft sequence=');
x=zeros(1,N);
for n=0:N-1
for k=0:N-1
x(n+1)=x(n+1)+X(k+1)*exp((i*2*pi*k*n/N));
xn=x./N;
end
end
disp('the idft sequence is')
disp(xn)
n=0:length(xn)-1;
stem(n,xn)
xlabel('time');
ylabel('amplitude');
title('idft sequence');
OUTPUT:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 55
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 56
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 57
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
20 0 0 0
20 0 0 0
𝑵−𝟏 𝑵−𝟏
Equation:∑𝒌=𝟎 | 𝐱(𝐧)|𝟐 = 1/N ∑𝒌=𝟎 | 𝐱(𝐊)|𝟐
PROGRAM:
clc;
x=input('enter the input sequence');
N=input('enter the number of DFT point');
X=fft(x,N)
Energy 1 =sum(x.^2);
disp(‘the value of energy1 are’)
disp (energy 1)
Energy2=1/N* sum (abs(x). ^2);
disp (‘the value of energy 2 are’)
disp(energy2)
If (energy1==energy2)
disp(‘DFT satisfies parsvel theorem”)
else
disp(‘dft does not satisfies parsevel’s theorem ‘)
end
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 58
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 59
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Increasing beta widens the main lobe and decreases the amplitude of the
sidelobes (i.e., increases the attenuation).
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 60
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
AIM: Design and implementation of FIR filter to meet given specifications (low pass
filter using BLACKMAN window).
OBJECTIVE:
1. To design the FIR filter by Blackman window using the inbuilt MATLAB function
“FIR1 and Blackman”.
2. To verify the result by theoretical calculations.
PROGRAM:
clc;
fcut=input('enter the cutoff frequency=');
fs=input('enter the sampling frequency=');
N=input('enter the order of the filter=');
wc=2*fcut/fs;
L=N+1;
w=blackman(L);
b=fir1(N,wc,'low',w)
freqz(b)
title('FIR filter using blackman');
OUTPUT:
Columns 1 through 9
Columns 10 through 11
0.0026 0
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 61
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 62
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
AIM: Design and implementation of FIR filter to meet given specifications (low pass
filter using hamming window).
OBJECTIVE:
1. To design the FIR filter by Hamming window using the inbuilt MATLAB function
“FIR1 and hamming”.
2. To verify the result by theoretical calculations.
PROGRAM:
clc;
fcut=input('enter the cutoff frequency=');
fs=input('enter the sampling frequency=');
N=input('enter the order of the filter=');
wc=2*fcut/fs;
L=N+1;
w=hamming(L);
b=fir1(N,wc,'low',w)
freqz(b)
title('FIR filter using hamming');
OUTPUT:
Columns 10 through 11
0.0093 0.0000
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 63
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 64
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
fcut=input('enter the cutoff frequency=');
fs=input('enter the sampling frequency=');
N=input('enter the order of the filter=');
wc=2*fcut/fs;
L=N+1;
w=hanning(L);
b=fir1(N,wc,'low',w)
freqz(b)
title('FIR filter using hanning');
OUTPUT:
b=
Columns 1 through 9
Columns 10 through 11
0.0130 0.0000
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 65
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
-20
-40
Magnitude (dB)
-60
-80
-100
-120
-140
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
-100
Phase (degrees)
-200
-300
-400
-500
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 66
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
AIM: Design and implementation of FIR filter to meet given specifications (low pass
filter using Kaiser Window).
OBJECTIVE:
1. To design the FIR filter by Kaiser Window using the inbuilt MATLAB function
“FIR1 and Kaiser”.
2. To verify the result by theoretical calculations.
PROGRAM:
clc;
fcut=input('enter the cutoff frequency=');
fs=input('enter the sampling frequency=');
N=input('enter the order of the filter=');
wc=2*fcut/fs;
L=N+1;
w=kaiser(L);
b=fir1(N,wc,'low',w)
freqz(b)
title('FIR filter using kaiser');
OUTPUT:
b=
Columns 1 through 9
Columns 10 through 11
0.0388 0.0000
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 67
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 68
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
AIM: Design and implementation of FIR filter to meet given specifications (low pass
filter using rectwin window).
OBJECTIVE:
1. To design the FIR filter by Rectwin window using the inbuilt MATLAB function
“FIR1 and rectwin”.
2. To verify the result by theoretical calculations.
PROGRAM:
clc;
fcut=input('enter the cutoff frequency=');
fs=input('enter the sampling frequency=');
N=input('enter the order of the filter=');
wc=2*fcut/fs;
L=N+1;
w=rectwin(L);
b=fir1(N,wc,'low',w)
freqz(b)
title('FIR filter using rectwin');
OUTPUT:
b=
Columns 1 through 9
Columns 10 through 11
0.0399 0.0000
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 69
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 70
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OBJECTIVE:
1- To design the BUTTERWORTH filter to meet the given specification using the
MATLAB functions BUTTORD and BUTTER
2- Bilinear transformation for analog-to-digital filter conversion using function
“BILINEAR”
3- To design the CHEBYSHEV filter to meet the given specification using the
MATLAB function cheb1ord and cheby1
4- To verify the result by theoretical calculations.
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 71
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 72
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
the imaginary axis in the complex plane at the angular frequencies in rad/s specified in
real vector w, where w is a vector containing more than one frequency.
[h,w] = freqs(b,a,n) uses n frequency points to compute the frequency response,
h, where n is a real, scalar value. The frequency vector w is auto-generated and has
length n. If you omit n as an input, 200 frequency points are used. If you do not need the
generated frequency vector returned, you can use the form h = freqs (b,a,n) to return
only the frequency response, h.
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 73
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
This transformation maps the jΩ axis (from Ω = –∞ to +∞) repeatedly around the unit
circle (ejw, from ω = –π to π) by
Ω
𝑤 = 2 tan−1
2𝑓𝑠
Impinvar: Impulse invariance method for analog-to-digital filter conversion
Syntax:
[bz,az] = impinvar(b,a,fs)
[bz,az] = impinvar(b,a,fs,tol)
Description:
[bz,az] = impinvar(b,a,fs) creates a digital filter with numerator and denominator
coefficients bz and az, respectively, whose impulse response is equal to the impulse
response of the analog filter with coefficients b and a, scaled by 1/fs. If you leave out the
argument fs, or specify fs as the empty vector , it takes the default value of 1 Hz.
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 74
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
n=
wn =
2.0032e+03
z=
1.0e+06 *
0 0 4.0129
p=
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 75
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
1.0e+06 *
Num/den =
4012915.1817
--------------------------------
s^2 + 2832.9897 s + 4012915.1817
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 76
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
fp=input('enter the passband edge frequency=');
fs=input('enter the stopband edge frequency=');
ap=input('enter the passband attenuation=');
as=input('enter the stopband attenuation=');
wp=2*pi*fp;
ws=2*pi*fs;
[n,wn]=buttord(wp,ws,ap,as,'s')
[z,p]=butter(n,wn,'high','s')
disp('the order of highpass filter is')
disp(n)
printsys(z,p)
freqs(z,p)
title('analog butterworth high pass filter');
OUTPUT:
wn =
2.0032e+03
z=
1 0 0
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 77
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
p=
1.0e+06 *
Num/den =
S^2
--------------------------------
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 78
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
fp=input('enter the passband edge frequency =');
fs=input('enter the stopband edge frequency =');
Ap=input('enter the passsband attenuation =');
As=input('enter the stopband attenuation');
wp=2*pi*fp;
ws=2*pi*fs;
[n,wp]=cheb1ord(wp,ws,Ap,As,'s');
[b,a]=cheby1(n,wp,Ap,'low','s');
disp('the order of lowpass filter is')
disp(n)
printsys(b,a)
freqs(b,a)
title('chebyshev');
OUTPUT:
1.2984e-78
----------
s^2 + 4.5
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 79
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 80
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
fp=input('enter the passband edge frequency =');
fs=input('enter the stopband edge frequency =');
Ap=input('enter the passsband attenuation =');
As=input('enter the stopband attenuation');
wp=2*pi*fp;
ws=2*pi*fs;
[n,wp]=cheb1ord(wp,ws,Ap,As,'s');
[b,a]=cheby1(n,wp,Ap,'high','s');
disp('the order of highpass filter is')
disp(n)
printsys(b,a)
freqs(b,a)
title('chebyshev');
OUTPUT:
num/den =
2.8853e-79 s^2
--------------
s^2 + 18
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 81
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 82
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
OUTPUT:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 83
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 84
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
clc;
fs=input('enter the sampling frequency=');
pf=input('enter the passband edge frequency=');
sf=input('enter the stopband frequency=');
ap=input('enter the passband attenuation=');
as=input('enter the stopband attenuation=');
wp=2*pi*(pf/fs);
ws=2*pi*(sf/fs);
[n,wn]=buttord(wp,ws,ap,as,'s');
[b,a]=butter(n,wn,'low','s');
disp('the order of the filter is')
disp(n)
disp('system function is analog')
printsys(b,a,'s');
fs=1;
[z,p]=impinvar(b,a,fs);
disp('system function is digital')
printsys(z,p,'z');
freqz(z,p)
title('lowpass filter');
OUTPUT:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 85
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
num/den =
0.45381 z
-------------------------
z^2 - 0.74812 z + 0.24256
Graph:
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 86
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
HARDWARE PROGRAMS
PROGRAM:
#include<stdio.h>
void main()
{
int m=4;
int n=4;
int i=0,j;
int x[10]={1,2,1,1};
int h[10]={1,2,3,4};
int*y=(int*)0x0000100;
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 87
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
PROGRAM:
#include<stdio.h>
#include<math.h>
void main()
{
float x[4]={1,2,3,4};
float h[4]={1,2,1,1};
float*y=(float*)0x0000100;
int N=4;
int k,n,i;
for(n=0;n<N;n++)
{
y[n]=0;
for(k=0;k<N;k++)
{
i=(n-k)%N;
if(i<0)
i=i+n;
y[n]=y[n]+h[k]*x[i];
}
printf("%f\t",y[n]);
}
}
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 88
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
#include <stdio.h>
float x[50],y[50];
void main()
{
float a0,a1,a2,b0,b1,b2;
int i,j,N=5;
a0=1;
a1=-3.5;
a2=1.5;
b0=3;
b1=-4;
b2=0;
x[0]=1;
for (i=1;i<N;i++)
x[i]=0;
for (j=0;j<N;j++)
{
y[j]=b0*x[j]-a0*y[j];
if (j>0)
y[j]=y[j]+b1*x[j-1]-a1*y[j-1];
if ((j-1)>0)
y[j]=y[j]+b2*x[j-2]-a2*y[j-2];
printf("%f\t",y[j]);
}
}
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 89
DIGITAL SIGNAL PROCESSING LABORATORY (17ECL57)
#include<stdio.h>
#include<math.h>
void main()
{
float x[8]={1,1,1,1,0,0,0,0};
float w;
int n,k,k1,N=8,xlen=8;
float*y=(float*)0x0000100;
float*y1=(float*)0x0000000;
for(k=0;k<2*N;k+2)
{
y[k]=0;
y1[k+1]=0;
k1=k/2;
for(n=0;n<xlen;n++)
{
w=2*3.14*k1*n/N;
y[k]=y[k]+x[n]*cos(w);
y1[k+1]=y1[k+1]+x[n]*sin(w);
}
printf("%f+j%f\n",y[k],y1[k+1]);
}
}
Dept of ECE, BGSIT, B.G Nagara, Nagamangala Taluk, Mandya District. Page 90