DSP Lab Manuals1
DSP Lab Manuals1
1 D/F
Channabasaveshwara Institute of Technology
(Affiliated to VTU, Belagavi & Approved by AICTE, New Delhi)
(NAAC Accredited & ISO 9001:2015 Certified Institution)
NH206(B.H. Road), Gubbi, Tumkur–572216.Karnataka.
B.E - V Semester
Lab Manual 2024-25
Name:
USN:
Batch: Section:
Channabasaveshwara Institute of Technology
(Affiliated to VTU, Belagavi & Approved by AICTE, New Delhi)
. (NAAC Accredited & ISO 9001:2015 Certified Institution)
NH206(B.H. Road), Gubbi, Tumkur–572216.Karnataka.
Manual
2. Mr. Sreenivasa T V
Assistant Professor
Approved by:
Dr. Suresh D S
Professor & HOD,
Dept. Of ECE
.
Channabasaveshwara Institute of Technology
(Affiliated to VTU, Belagavi & Approved by AICTE, New Delhi)
(NAAC Accredited & ISO 9001:2015 Certified Institution)
NH206(B.H. Road), Gubbi, Tumkur–572216.Karnataka.
INSTITUTE VISION
INSTITUTE MISSION
QUALITY POLICY
events.
requirements.
Channabasaveshwara Institute of Technology
(Affiliated to VTU, Belagavi & Approved by AICTE, New Delhi)
(NAAC Accredited & ISO 9001:2015 Certified Institution)
NH206(B.H. Road), Gubbi, Tumkur–572216.Karnataka.
PEO1: Apply Mathematical, Scientific and Engineering skills for solving problems in the
areas of Electronics and Communication Engineering.
PEO4: Inculcate Professional ethics, human values, team work for solving Engineering
problems and contribute to societal needs.
PSO2: Design and Develop Communication Systems as per Real Time Application and
Current Trends.
COURSE OBJECTIVES
1. Preparation: To prepare students with fundamental knowledge/ overview in the field
of Digital Signal Processing
COURSE OUTCOMES
CO1: Analyze the different types of signals and systems used in digital signal processing.
CO2: Compute the response of an LTI system using time and frequency domain
techniques.
CO3: Develop algorithms for the efficient computations of DFT and IDFT.
CO4: Design of digital FIR filters for the given specifications using different window
methods.
CO5: Design of digital IIR digital filters using bilinear transformation method.
Channabasaveshwara Institute of Technology
(Affiliated to VTU, Belagavi & Approved by AICTE, New Delhi)
(NAAC Accredited & ISO 9001:2015 Certified Institution)
NH206(B.H. Road), Gubbi, Tumkur–572216.Karnataka.
PROGRAM OUTCOMES
Determine H(z) and sketch its pole zero plot. b) Plot |H(ejω) | and ∠ H(ejω)
4 Consider a causal system y(n) = 0.9y(n-1) +x(n).
Observation
book written
Every lab at each lab
session +
Record & CO1 – CO5
(Avg. of all 15 Record
Observation
CIE Students experiment submitted at
marks) each lab
+
Viva
CO1 – CO5
IA Test one 10 Blue Books
DO’S: -
Uniform and ID card are must.
Strictly follow the procedures for conduction of experiments.
Records have to be submitted every week for evaluation.
Chairs and stools should be kept under the workbenches when not in use.
After the lab session, switch off every supply, disconnect and disintegrate the
experiments and return the components.
Keep your belongings in designated area.
Never use damaged instruments, wires or connectors. Hand these parts to the
instructor/ teaching assistant.
Sign the log book when you enter/leave the laboratory.
DONT’S: -
Don't touch open wires unless you are sure that there is no voltage. Always
disconnect the plug by pulling on the connector body not by the cable. Switch off the
supply while you make changes to the experiment.
Don’t leave the experiment table unattended when the experimental setup supply is
on.
Students are not allowed to work in laboratory alone or without presence of the
teaching staff/ instructor.
No additional material should be carried by the students during regular labs.
Avoid stepping on electrical wires or any other computer cables
University
Evaluation of DIGITAL SIGNAL PROCESSING LABORATORY (IPCC) weightage
Marks
(BEC502)
INTRODUCTION TO MATLAB
MATLAB stands for Matrix Laboratory. It is a high-performance language
that is used for technical computing. It was developed by Cleve Molar of the
company MathWorks. INC in the year 1984.It is written in C, C++, Java. It
allows matrix manipulations, plotting of functions, implementation of
algorithms and creation of user interfaces. It is both a programming language
as well as a programming environment. It allows the computation of
statements in the command window itself.
The user can create their own functions in the MATLAB language. Thus, they
are not restricted to using only the built-in functions. Additional toolboxes are
provided by MATLAB. These toolboxes were created for common uses such as
neural networks, symbolic computations, image processing, control system
design, and statistics.
Features of MATLAB
our data across any of the three dimensions (1D, 2D, and 3D). We can plot
the functions and customize them also according to our needs like
changing bullet points, line color and displaying/not displaying grid.
2. Using Editor: Multiple lines of code can be written here and only
after pressing the run button (or F5) will the code be executed. It is
always a good practice to write clc, clear and close all in the beginning
of the program.Note: Statements ending with a semicolon will not be
displayed in the command window, however, their values will be
displayed in the workspace. Any statement followed by % in MATLAB
is considered as a comment
Function Description
Function Description
Advantages of MATLAB
Disadvantages of MATLAB
Step2: Click on New button and select M-File, An Editor window will open as
follows
Step7: After Correcting the error click on the RUN button again, MATLAB
program will be Executed and result will be displayed in command window and
respective result will be displayed.
EXPERIMENT NO 1
PROGRAM TO GENERATE THE FOLLOWING DISCRETE
TIME SIGNALS.
a) UNIT SAMPLE SEQUENCE b) UNIT STEP SEQUENCE
c) EXPONENTIAL SEQUENCE d) SINUSOIDAL SEQUENCE
e) RANDOM SEQUENCE
Program:
clc;
clear all;
N =input('enter the value of time constant'); % Length of sequence
n = -N/2:N/2; % Define the time index range
x = (n == 0);% Create the unit sample sequence (impulse function)
stem(n, x, 'filled');
xlabel('n');
ylabel('x[n]');
title('Unit Sample Sequence');
grid on;
Result 1a:
Program:
clc;
clear all;
N =input('enter the value of time constant'); % Length of sequence
n = -N/2:N/2; % Define the time index range
u = (n >= 0);% Create the unit step sequence
stem(n, u, 'filled');
xlabel('n');
ylabel('u[n]');
title('Unit Step Sequence');
grid on;
Result 1b:
Program:
clc;
clear all;
N =input('enter the value of time constant'); % Length of sequence
n = 0:N-1; % Time index ranging from 0 to N-1
A = input('enter the value of a Amplitude');
a = input('enter the value of a Growth constant');
b = input('enter the value of a Decay constant');
% Define the exponential factor
x = A * a.^n; % Growing signal
y = A * -b.^n;% Decaying signal
% Plot the generated exponential signals
figure;
subplot(2, 1, 1);
plot(n, x);
xlabel('Time');
ylabel('Amplitude');
title('Growing Exponential Signal');
subplot(2, 1, 2);
plot(n, y);
xlabel('Time');
ylabel('Amplitude');
title('Decaying Exponential Signal');
Result 1c:
enter the value of time constant20
enter the value of a Amplitude5
enter the value of a Growth constant2
enter the value of a Decay constant2
clc;
clear all;
N =input('enter the value Length of the random sequence');
x = rand(1, N); % Generates a 1xN array of random numbers between
0 and 1
stem(x, 'filled');
title('Random Sequence');
xlabel('Index');
ylabel('x[n]');
grid on;
Result 1d:
EXPERIMENT NO 2
PROGRAM TO PERFORM THE FOLLOWING
OPERATIONS ON SIGNALS.
a) SIGNAL ADDITION b) SIGNAL MULTIPLICATION c) SCALING d) SHIFTING,
e) FOLDING
operation Program:
clc;
clear all;
x =input('enter the value of first signal Sequence');
y =input('enter the value of Second signal Sequence');
z=x+y;
figure;
subplot(3, 1, 1);
stem(x);
xlabel('Time');
ylabel('Amplitude');
title('First Signal');
subplot(3, 1, 2);
stem(y);
xlabel('Time');
ylabel('Amplitude');
title('Second Signal');
subplot(3, 1, 3);
stem(z);
xlabel('Time');
ylabel('Amplitude');
title('Addition of Two Signal Z=X+Y');
Result 2a:
enter the value of first signal Sequence [1 2 3 4]
Program:
clc;
clear all;
T=input('enter the length of Sequence');
t=0:0.01:T-1;
f=input('enter the value of Frequency');
t1=2*pi*f*t;
x1=sin(t1);
subplot(3,1,1)
stem(t,x1)
title('First Signal
X1') xlabel('Time');
ylabel('Amplitude')
grid on;
x2=cos(t1);
subplot(3,1,2)
stem(t,x2)
title('Second Signal X2')
xlabel('Time');
ylabel('Amplitude')
grid on;
y=x1.*x2; % Multiplication
subplot(3,1,3)
stem(t,y)
title('Multiplication Result Signal Y=x1*x2')
xlabel('Time')
ylabel('Amplitude')
grid on;
Result 2b:
enter the length of Sequence2
enter the value of Frequency4
Program:
clc;
clear all;
T=input('enter the length of Sequence');
t=0:0.01:T-1;
f=input('enter the value of Frequency');
t1=2*pi*f*t;
x=sin(t1);
subplot(3,1,1)
plot(t,x)
title('Original
Signal') xlabel('Time')
ylabel('Amplitude')
grid on;
y=sin(t1/2);
subplot(3,1,2)
plot(t,y)
title('Expanded
Signal') xlabel('Time')
ylabel('Amplitude')
grid on;
z=sin(t1*2);
subplot(3,1,3)
plot(t,z)
title('Compressed Signal')
xlabel('Time')
ylabel('Amplitude')
grid on;
Result 2c:
enter the length of Sequence4
enter the value of Frequency2
Program:
clc;
clear all;
N=input('Enter the length of Sequence');
x =input('Enter the value of Signal Sequence of Length N');
n1=input('Enter the amount to be delayed');
n2=input('Enter the amount to be advanced');
n=0:N-1;
subplot(3,1,1);
stem(n,x);
title('Signal x(n)');
m=n+n1;
y=x;
subplot(3,1,2);
stem(m,y);
title('Delayed signal x(n-n1)');
t=n-n2;
z=x;
subplot(3,1,3);
stem(t,z);
title('Advanced signal x(n+n2)');
Result 2d:
Enter the length of Sequence4
Enter the value of Signal Sequence of Length N[1 2 3 4]
Enter the amount to be delayed2
Enter the amount to be advanced3
Program:
clc;
clear all;
N=input('Enter the length of Sequence');
x =input('Enter the value of Signal Sequence of Length N');
n=0:N-1;
subplot(2,1,1)
stem(n,x)
title('Original
Signal') xlabel('Time')
ylabel('Amplitude')
grid on;
y=fliplr(x);
subplot(2,1,2)
stem(n,y)
title('Folded
Signal')
xlabel('Time')
ylabel('Amplitude')
grid on;
Result 2e:
Enter the length of Sequence4
Enter the value of Signal Sequence of Length N[1 2 3 4]
EXPERIMENT NO 3
PROGRAM TO PERFORM CONVOLUTION OF TWO
GIVEN SEQUENCES (WITHOUT USING BUILT-IN
FUNCTION) AND DISPLAY THE
SIGNALS
Program:
clc;
clear all;
x =input('Enter the value of First Signal Sequence x[n]');
h =input('Enter the value of Second Signal Sequence
h[n]');
% convolution
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0;
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
figure;
subplot(3,1,1);
stem(x, 'filled');
xlabel('n');
ylabel('x[n]');
title(' First Signal Sequence x[n]');
grid on;
subplot(3,1,2);
stem(h, 'filled');
xlabel('n');
ylabel('h[n]');
title(' Second Signal Sequence h[n]');
grid on;
subplot(3,1,3);
stem(Y,'filled');
ylabel('Y[n]');
xlabel('n');
grid on;
title('Convolution of Two Signals without conv function');
Result 3a:
Enter the value of First Signal Sequence x[n][1 2 3 1]
Enter the value of Second Signal Sequence h[n][1 1 1]
Result 3b:
Enter the value of First Signal Sequence x[n][1 1 1 1]
Enter the value of Second Signal Sequence h[n][1 2 3 1]
EXPERIMENT NO 4
CONSIDER A CAUSAL SYSTEM y(n) = 0.9y(n-1) +x(n).
Program:
clc;
clear all;
numerator = [1]; % Numerator of H(z)
denominator = [1 -0.9]; % Denominator of H(z)
Result :
EXPERIMENT NO 5
COMPUTATION OF N POINT DFT OF A GIVEN
SEQUENCE (WITHOUT USING BUILT-IN FUNCTION)
AND TO PLOT THE MAGNITUDE & PHASE SPECTRUM.
Program:
clc;
clear all;
x = input('Enter the value of Signal Sequence x[n]');
N = length(x); % Length of the sequence
X = zeros(1, N);
Result 5a:
Enter the value of Signal Sequence x[n][1 2 3 4]
magnitude_X = 10.0000 2.8284 2.0000 2.8284
phase_X = 0 135.0000 -180.0000 -135.0000
Result 5b:
Enter the value of Signal Sequence x[n][1 1 2 2 3 3]
magnitude_X = 12.0000 3.0000 1.7321 0.0000 1.7321 3.0000
phase_X = 0 120.0000 150.0000 -90.0000 -150.0000 -120.0000
EXPERIMENT NO 6
USING THE DFT AND IDFT, COMPUTE THE
FOLLOWING FOR ANY TWO GIVEN SEQUENCES
a) CIRCULAR CONVOLUTION
b) LINEAR CONVOLUTION
Program:
clc;
clear all;
x = input('Enter the value of Signal Sequence x[n]');
h = input('Enter the value of Signal Sequence h[n]');
N = max(length(x), length(h));
x_padded = [x, zeros(1, N - length(x))];
h_padded = [h, zeros(1, N - length(h))];
% Compute the DFT of both sequences
X = fft(x_padded)
H = fft(h_padded)
Y = X .* H % Multiply the DFTs (element-wise)
y = ifft(Y);% Compute the IDFT to get the circular convolution
disp('Circular Convolution Result: y');
disp(y);
Result 6a1:
Enter the value of Signal Sequence x[n][1 2 3 4]
Enter the value of Signal Sequence h[n][1 1 1 1]
X =10.0000 + 0.0000i -2.0000 + 2.0000i -2.0000 + 0.0000i -2.0000 - 2.0000i
H=4 0 0 0
Y = 40 0 0 0
Circular Convolution Result:
10 10 10 10
Result 6a2:
Enter the value of Signal Sequence x[n][2 3 1 1]
Enter the value of Signal Sequence h[n][1 3 5 3]
X =7.0000 + 0.0000i 1.0000 - 2.0000i -1.0000 + 0.0000i 1.0000 + 2.0000i
H = 12 -4 0 -4
Y =84.0000 + 0.0000i -4.0000 + 8.0000i 0.0000 + 0.0000i -4.0000 - 8.0000i
Circular Convolution Result: y
19 17 23 25
Program:
clc;
clear all;
x = input('Enter the value of Signal Sequence x[n]');
h = input('Enter the value of Signal Sequence h[n]');
Lx = length(x);
Lh = length(h);
N = Lx + Lh - 1; % Length of the linear convolution result
x_padded = [x, zeros(1, N - Lx)];
h_padded = [h, zeros(1, N - Lh)];
% Compute the DFT of both sequences
X = fft(x_padded)
H = fft(h_padded)
Y = X .* H % Multiply the DFTs (element-wise)
y = ifft(Y); % Compute the IDFT to get the linear convolution
disp('Linear Convolution Result: y');
disp(y);
Result 6b:
Enter the value of Signal Sequence x[n][1 2 3 4]
Enter the value of Signal Sequence h[n][2 3 1 1]
X =
Columns 1 through 5
Columns 6 through 7
Columns 6 through 7
Columns 6 through 7
EXPERIMENT NO 7
VERIFICATION OF LINEARITY PROPERTY, CIRCULAR
TIME SHIFT PROPERTY AND CIRCULAR FREQUENCY
SHIFT PROPERTY OF DFT.
7a) Verification of Linearity property of DFT
Linearity property: DFT {a.x1(n)+b.x2(n)} = a.X1(K )+ b.X2(K)
Program:
clc;
clear all;
x1 = input('Enter the value of Signal Sequence x1[n]');
x2 = input('Enter the value of Signal Sequence x2[n]');
% Display results
disp('DFT of Linear Combination:');
disp(X_combined);
Result 7a1:
Result 7a2:
Program:
clc;
clear all;
N = input('Enter the Length of the signal');
x= input('Enter the input sequence=');
m = input('Enter the Number of circular shifts=');
X = fft(x);% Compute DFT of the original signal
x_shifted = circshift(x, m);% Circularly shift the signal by m
X_shifted = fft(x_shifted)% Compute DFT of the shifted signal
subplot(2,1,1);
stem(0:N-1, abs(X_shifted), 'filled');
title('Magnitude of DFT of Shifted Signal');
xlabel('Frequency Index');
ylabel('Magnitude');
subplot(2,1,2);
stem(0:N-1, abs(expected_X_shifted), 'filled');
title('Magnitude of Expected Phase-shifted DFT');
xlabel('Frequency Index');
ylabel('Magnitude');
Result 7b1:
Enter the Length of the signal4
Enter the input sequence=[1 2 3 4]
Enter the Number of circular shifts=2
X_shifted =
10.0000 + 0.0000i 2.0000 - 2.0000i -2.0000 + 0.0000i 2.0000 + 2.0000i
expected_X_shifted =
10.0000 + 0.0000i 2.0000 - 2.0000i -2.0000 - 0.0000i 2.0000 + 2.0000i
Result 7b2:
Enter the Length of the signal4
Enter the input sequence=[ 5 6 7 3]
Enter the Number of circular shifts=3
X_shifted =
21.0000 + 0.0000i 3.0000 - 2.0000i -3.0000 + 0.0000i 3.0000 + 2.0000i
expected_X_shifted =
21.0000 + 0.0000i 3.0000 - 2.0000i -3.0000 - 0.0000i 3.0000 + 2.0000i
Program:
clc;
clear all;
N = input('Enter the Length of the signal');
x= input('Enter the input sequence=');
l = input('Enter the Number of circular shifts=');
X = fft(x);% Compute DFT of the original signal
subplot(2,1,1);
stem(0:N-1, abs(X_shifted), 'filled');
title('Magnitude of DFT of Frequency-shifted Signal');
xlabel('Frequency Index');
ylabel('Magnitude');
subplot(2,1,2);
stem(0:N-1, abs(expected_X_shifted), 'filled');
title('Magnitude of Circular frequency-shifted DFT');
xlabel('Frequency Index');
ylabel('Magnitude');
Result 7c1:
Enter the Length of the signal4
Enter the input sequence=[1 2 3 4]
Enter the Number of circular shifts=2
X_shifted =
expected_X_shifted =
Result 7c1:
Enter the Length of the signal4
Enter the input sequence=[5 6 2 3]
Enter the Number of circular shifts=3
X_shifted =
3.0000 - 3.0000i -2.0000 + 0.0000i 3.0000 + 3.0000i 16.0000 - 0.0000i
expected_X_shifted =
3.0000 + 3.0000i 16.0000 + 0.0000i 3.0000 - 3.0000i -2.0000 + 0.0000i
EXPERIMENT NO 8
DEVELOP DECIMATION IN TIME RADIX-2 FFT
ALGORITHM WITHOUT USING BUILT-IN FUNCTIONS
Program:
clc;
clear all;
x= input('Enter the input sequence=');
N = length(x);
% Bit-reversal permutation
num_bits = log2(N);
reversed_indices = bit_reverse(0:N-1, num_bits);
x = x(reversed_indices + 1);
% FFT computation
% Initial length of the FFT
current_len = 2;
for k = 1:current_len:N
even = x(k:k+half_len-1);
odd = x(k+half_len:k+current_len-1);
current_len = current_len * 2;
end
Result 8a:
Enter the input sequence=[1 2 3 4 5 6 7 8]
FFT of the input:
Columns 1 through 5
Columns 6 through 8
Result 8b:
Enter the input sequence=[1 1 0 0 -1 -1 0 0 ]
FFT of the input:
Columns 1 through 5
Columns 6 through 8
EXPERIMENT NO 9
DESIGN AND IMPLEMENTATION OF DIGITAL LOW
PASS FIR FILTER USING A WINDOW TO MEET THE
GIVEN SPECIFICATIONS
Program:
clc;
clear all;
close all;
fs= input('Enter the Value of Sampling frequency (fs) in Hz=');
fc= input('Enter the Value of Cutoff frequency (fc)in Hz=');
N= input('Enter the Order (ODD Order)')
wc=fc/(fs/2);
h=fir1(N,wc,'low',hamming(N+1));
freqz(h,1,1024,fs)
Result 9a:
Enter the Value of Sampling frequency (fs) in Hz=8000
Enter the Value of Cutoff frequency (fc)in Hz=2000
Enter the Order (ODD Order)30
Result 9a:
Enter the Value of Sampling frequency (fs) in Hz=2000
Enter the Value of Cutoff frequency (fc)in Hz=500
Enter the Order (ODD Order)20
EXPERIMENT NO 10
DESIGN AND IMPLEMENTATION OF DIGITAL HIGH
PASS FIR FILTER USING A WINDOW TO MEET THE
GIVEN SPECIFICATIONS
Program:
clc;
clear all;
close all;
fs= input('Enter the Value of Sampling frequency (fs) in Hz=');
fc= input('Enter the Value of Cutoff frequency (fc)in Hz=');
N= input('Enter the Order (ODD Order)');
wc=fc/(fs/2);
h=fir1(N,wc,'high',hamming(N+1));
freqz(h,1,1024,fs)
Result 10a:
Enter the Value of Sampling frequency (fs) in Hz=8000
Enter the Value of Cutoff frequency (fc)in Hz=2000
Enter the Order (ODD Order)30
Result 10b:
Enter the Value of Sampling frequency (fs) in Hz=2000
Enter the Value of Cutoff frequency (fc)in Hz=500
Enter the Order (ODD Order)20
EXPERIMENT NO 11
DESIGN AND IMPLEMENTATION OF DIGITAL IIR
BUTTERWORTH LOW PASS FILTER TO MEET THE
GIVEN SPECIFICATIONS.
Program:
clc;
clear all
fs=input('Enter the Value of Sampling frequency (fs) in Hz=');
kp=input('Enter the Value of Pass band Attenuation in dB=');
ks=input('Enter the Value of Stop band Attenuation in dB=');
fp=input('Enter the Value of Pass band Frequency in Hz=');
fstop=input('Enter the Value of Stop band Frequency in Hz=');
wp=fp/(fs/2);
wstop=fstop/(fs/2);
[N, wc]=buttord(wp,wstop,kp,ks)
[b, a]=butter(N,wc,'low')
freqz(b,a,1000,fs)
Result 11a:
Enter the Value of Sampling frequency (fs) in Hz=1000
Enter the Value of Pass band Attenuation in dB=3
Enter the Value of Stop band Attenuation in dB=60
Enter the Value of Pass band Frequency in Hz=40
Enter the Value of Stop band Frequency in Hz=150
N =5
wc =0.0810
b = 1.0e-03 *0.0227 0.1136 0.2272 0.2272 0.1136 0.0227
a =1.0000 -4.1768 7.0358 -5.9686 2.5478 -0.4375
Result 11b:
Enter the Value of Sampling frequency (fs) in Hz=5000
Enter the Value of Pass band Attenuation in dB=7
Enter the Value of Stop band Attenuation in dB=70
Enter the Value of Pass band Frequency in Hz=50
Enter the Value of Stop band Frequency in Hz=500
N= 4
wc = 0.0276
b =1.0e-04 *0.0315 0.1259 0.1888 0.1259 0.0315
a =1.0000 -3.7737 5.3464 -3.3701 0.7974
EXPERIMENT NO 12
DESIGN AND IMPLEMENTATION OF DIGITAL IIR
BUTTERWORTH HIGH PASS FILTER TO MEET THE
GIVEN SPECIFICATIONS.
Program:
clc;
clear all
fs=input('Enter the Value of Sampling frequency (fs) in Hz=');
kp=input('Enter the Value of Pass band Attenuation in dB=');
ks=input('Enter the Value of Stop band Attenuation in dB=');
fp=input('Enter the Value of Pass band Frequency in Hz=');
fstop=input('Enter the Value of Stop band Frequency in Hz=');
wp=fp/(fs/2);
wstop=fstop/(fs/2);
[N, wc]=buttord(wp,wstop,kp,ks)
[b, a]=butter(N,wc,'high')
freqz(b,a,1000,fs)
Result 12a:
Enter the Value of Sampling frequency (fs) in Hz=1000
Enter the Value of Pass band Attenuation in dB=3
Enter the Value of Stop band Attenuation in dB=60
Enter the Value of Pass band Frequency in Hz=40
Enter the Value of Stop band Frequency in Hz=150
N= 5
wc =0.0810
b =0.6615 -3.3073 6.6145 -6.6145 3.3073 -0.6615
a =1.0000 -4.1768 7.0358 -5.9686 2.5478 -0.4375
Result 12a:
Enter the Value of Sampling frequency (fs) in Hz=5000
Enter the Value of Pass band Attenuation in dB=7
Enter the Value of Stop band Attenuation in dB=70
Enter the Value of Pass band Frequency in Hz=50
Enter the Value of Stop band Frequency in Hz=500
N=4
wc =0.0276
b = 0.8930 -3.5719 5.3579 -3.5719 0.8930
a = 1.0000 -3.7737 5.3464 -3.3701 0.7974
EXPERIMENT NO A
COMPUTE AUTOCORRELATION AND CROSS
CORRELATION OF SEQUENCES
Program:
clc;
clear all
x =input('Enter the Value of First sequence=');
y =input('Enter the Value of Second sequence=');
Result A:
Enter the Value of First sequence=[1 2 3 4]
Enter the Value of Second sequence=[5 6 2 3]
EXPERIMENT NO B
IMPULSE RESPONSE OF FIRST AND SECOND ORDER
SYSTEMS
Program:
clc;
close all;
clear all;
n=0:10;
%impulse response of first order system
b=[2 0 0];
a=[1 -0.9 0];
y=dimpulse(b,a,length(n));
subplot(2,1,1);
stem(n,y);
xlabel('n--->');
ylabel('amplitude');
title('impulse response of first order system');
b=[1 0 0];
a=[1 0.6 0.8];
y1=dimpulse(b,a,length(n));
subplot(2,1,2);
stem(n,y1);
xlabel('n---->');
ylabel('amplitude');
title('impulse response of second order system');
Result B:
EXPERIMENT NO C
PROGRAM TO PROVE THE PARSEVALS THEOREM
Program:
clc;
clear all;
close all;
x1=input('enter the 1st input seq=')
x2=input('enter the 2nd input seq=')
N=4;
X1=fft(x1,N)
X2=fft(x2,N)
y1=sum(x1.*conj(x2))
y2=sum(X1.*conj(X2))./N
if y1==y2
disp('parsevals theorem proved');
else
disp('parsevals theorem not proved')
end
Result C:
enter the 1st input seq=[1 2 3 4]
x1 =1 2 3 4
enter the 2nd input seq=[5 6 2 3]
x2 =5 6 2 3
X1 =
10.0000 + 0.0000i -2.0000 + 2.0000i -2.0000 + 0.0000i -2.0000 - 2.0000i
X2 =
16.0000 + 0.0000i 3.0000 - 3.0000i -2.0000 + 0.0000i 3.0000 + 3.0000i
y1 =
35
y2 =
35
EXPERIMENT NO D
COMPUTATION OF N POINT DFT OF A GIVEN
SEQUENCE BY USING BUILT-IN FUNCTION
AND TO PLOT THE MAGNITUDE & PHASE SPECTRUM.
Program:
clc;
clear all;
close all;
N=input('enter the value of N=');
n=0:1:(N-1);
x = input('enter the input signal, x(n)=');
X=fft(x,N)
mag=abs(X)
phase=angle(X)
subplot(3,1,1), stem(n,x);
xlabel('Time (s)');
ylabel('Amplitude');
title('Time domain - Input sequence');
subplot(3,1,2);
stem(n,mag)
xlabel('Frequency'); ylabel('|
X(k)|');
title('Frequency domain - Magnitude response');
subplot(3,1,3);
stem(n,unwrap(phase));
ylabel('phase(X(k))');
title('Frequency domain - phase response');
Result D1:
mag =
phase =
Result D2:
enter the value of N=6
enter the input signal, x(n)= [1 1 2 2 3 3]
X =12.0000 + 0.0000i -1.5000 + 2.5981i -1.5000 + 0.8660i
0.0000 + 0.0000i -1.5000 - 0.8660i -1.5000 - 2.5981i
mag =
12.0000 3.0000 1.7321 0 1.7321 3.0000
phase =
0 2.0944 2.6180 0 -2.6180 -2.0944
EXPERIMENT NO E
PROGRAM TO PERFORM CONVOLUTION OF TWO
GIVEN SEQUENCES BY USING BUILT-IN FUNCTION
AND DISPLAY THE SIGNALS.
Program:
clc;
clear all;
x =input('Enter the value of First Signal Sequence x[n]');
h =input('Enter the value of Second Signal Sequence
h[n]'); y = conv(x, h);% convolution
figure;
subplot(3,1,1);
stem(x, 'filled');
xlabel('n');
ylabel('x[n]');
title(' First Signal Sequence x[n]');
grid on;
subplot(3,1,2);
stem(h, 'filled');
xlabel('n');
ylabel('h[n]');
title(' Second Signal Sequence h[n]');
grid on;
subplot(3,1,3);
stem(y,'filled');
ylabel('Y[n]');
xlabel('n');
grid on;
title('Convolution of Two Signals without conv function');
Result E1:
Enter the value of First Signal Sequence x[n][1 1 1 1] Enter
the value of Second Signal Sequence h[n][1 2 3 4]
Result E2:
Enter the value of First Signal Sequence x[n][1 2 3 1] Enter
the value of Second Signal Sequence h[n][1 1 1]
VIVA QUESTIONS
40. Difference between FIR low pass filter and high pass filter
41. List some advantages of digital filters over analog filters.
42. Write some differences between FIR and IIR filters.
43. What are the different methods to design IIR filters?
44. Why IIR filters are not reliable?
45. What are different applications of IIR filters?
46. What are advantages of IIR filters?
47. What are disadvantages of IIR filters?
48. Differentiate Butterworth and Chebyshev approximations.
49. What is meant by impulse response?
50. Difference between IIR low pass and High pass filters
51. What is sampling theorem?
52. What do you mean by process of reconstruction.
53. What are techniques of reconstructions.
54. What do you mean Aliasing? What is the condition to avoid aliasing for
sampling?
55. Write the conditions of sampling.
56. How many types of sampling there?
57. Explain the statement-t= 0:0.000005:0.058. In the above example what
does colon (: ) and semicolon (; ) denotes.
58. What is a) Under sampling b) nyquist plot c) Oversampling.
59. Write the MATLAB program for Oversampling.
60. What is the use of command ‘legend’?
61. Write the difference between built in function, plot and stem describe the
function.
62. What is the function of built in function and subplot?
63. What is linear convolution?
64. Explain how convolution syntax built in function works.
65. How to calculate the beginning and end of the sequence for the two sided
controlled output?
66. What is the total output length of linear convolution sum.
67. What is an LTI system? Describe impulse response of a function.20. What is
the difference between convolution and filter?
68. How to calculate output length of the linear and circular convolution
69. What is window method? How you will design an FIR filter using window
method.
70. What do you mean by cut-off frequency?