You are on page 1of 17

DSP LAB III B.

TECH I SEM

unit impulse signal 439 unit impulse sequence 439


1 1

0.8 0.8

0.6 0.6
amplitude

amplitude
0.4 0.4

0.2 0.2

0 0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
time n

unit step signal 439 unit step sequence 439


1 1

0.8 0.8

0.6 0.6
amplitude

amplitude
0.4 0.4

0.2 0.2

0 0
-2 0 2 4 6 8 10 -2 0 2 4 6 8 10
time n

square wave signal 439


2 2

1 1
amplitude

amplitude

0 0

-1 -1

-2 -2
0 0.05 0.1 0 0.05 0.1
time n
sawtooth wave signal 439 sawtooth wave sequence 439
2 2 square wave sequence 439

1 1
amplitude

amplitude

0 0

-1 -1

-2 -2
0 0.05 0.1 0 0.05 0.1
time n

DEPT. OF ECE, SVR ENGINEERING COLLEGE


DSP LAB III B.TECH I SEM

triangular wave signal 439 triangular wave sequence 439


2 2

1 1
amplitude

amplitude
0 0

-1 -1

-2 -2
0 0.05 0.1 0 0.05 0.1
time n
sinsoidal wave signal 439 sin wave sequence 439
2 2

1 1
amplitude

amplitude

0 0

-1 -1

-2 -2
0 0.05 0.1 0 0.05 0.1
time n

sinc signal 439 sinc sequence 439


1 1

0.5 0.5
amplitude

0 0

-0.5 -0.5
-5 0 5 0 50 100
time n
exponential signal 439 exponential sequence 439
800 800

600 600
amplitude

400 400

200 200

0 0
-10 0 10 20 -10 0 10 20
time n

Result: Various signals & sequences generated using Matlab software.


DEPT. OF ECE, SVR ENGINEERING COLLEGE
DSP LAB III B.TECH I SEM

Sine W aves
2
30 Hz
60 Hz
Sum
1.5

0.5
Signal

-0.5

-1

-1.5

-2
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1

Time

frequency response --- Magnitude)


2

1.5

0.5

0
0 20 40 60 80 100 120

frequency response --- Phase)


4

0
0 20 40 60 80 100 120

DEPT. OF ECE, SVR ENGINEERING COLLEGE


DSP LAB III B.TECH I SEM

input sequence 439


10
x(n)

0
0 0.5 1 1.5 2 2.5 3 3.5 4
n
impulse response 439
10
h(n)

0
0 0.5 1 1.5 2 2.5 3 3.5 4
n
linear convoluted response 439
100
y(n)

50

0
0 1 2 3 4 5 6 7 8
n

DEPT. OF ECE, SVR ENGINEERING COLLEGE


DSP LAB III B.TECH I SEM

stem (t2,y); xlabel('n' 'y(n)');


title ('second sequence after zero padding');
for n=1:N
k (n)=0;
for i=1:N
j=n-i+1;
if j<=0
j=N+j;
else
k(n)=k(n)+x(i)*y(j)
end;
end;
end;
subplot (3,1,3);
t3=0: 1: (a-1);
stem (t3,k); xlabel('n'); ylabel('y(n)'); title('circular convoluted result');

first sequence after zero padding 439


10
x(n)

0
0 0.5 1 1.5 2 2.5 3 3.5 4
n
second sequence after zero padding 439
10
y(n)

0
0 0.5 1 1.5 2 2.5 3 3.5 4
n
circular convoluted result 439
100
y(n)

50

0
0 0.5 1 1.5 2 2.5 3 3.5 4
n

enter first sequence[4 5 6 1 2]

enter second sequence[2 4 5 6 8]

k = 8 26 52 75 100

RESULT:- Thus the program for circular convolution is written using MATLAB and verified.

DEPT. OF ECE, SVR ENGINEERING COLLEGE


DSP LAB III B.TECH I SEM

sequence 1 439
10
amplitude

0
0 0.5 1 1.5 2 2.5 3 3.5 4
n
sequence 2 439
6
amplitude

0
0 0.5 1 1.5 2 2.5 3 3.5 4
n
cross correlated result 439
150
amplitude

100

50

0
-4 -3 -2 -1 0 1 2 3 4
lag index
Cross correlation of x(n) and delayed x(n) 439
20

10

-10
-8 -6 -4 -2 0 2 4 6 8
DSP LAB III B.TECH I SEM

1.0000 + 0.4142i 0
1.0000 + 2.4142i

Magnitude spectrum: 439 Phase spectrum: 439


4 1.5

3.5

0.5

2.5
Magnitude of X(k)

Phase of X(k)
2 0

1.5

-0.5

-1

0.5

0 -1.5
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
Length Length

PROGRAM: WITH OUT BUILTIN FUNCTION:

N = input('Enter the the value of N(Value of N in N-Point DFT)');

x = input('Enter the sequence for which DFT is to be calculated');

n=[0:1:N-1];

k=[0:1:N-1];

WN=exp(-1j*2*pi/N); % twiddle factor

nk=n'*k;

WNnk=WN.^nk;

Xk=x*WNnk;

disp(Xk);

MagX=abs(Xk) % Magnitude of calculated DFT

PhaseX=angle(Xk)*180/pi % Phase of the calculated DFT

figure(1);

subplot(2,1,1);

DEPT. OF ECE, SVR ENGINEERING COLLEGE


DSP LAB III B.TECH I SEM

title('MAGNITUDE PLOT ');

plot(k,MagX);

subplot(2,1,2);

plot(k,PhaseX)

title('PHASE PLOT ')

OUTPUT
Enter the the value of N(Value of N in N-Point DFT)8
Enter the sequence for which DFT is to be calculated[1 1 1 1 0 0 0 0]
Columns 1 through 5
4.0000 1.0000 - 2.4142i -0.0000 - 0.0000i 1.0000 - 0.4142i 0 - 0.0000i
Columns 6 through 8
1.0000 + 0.4142i 0.0000 - 0.0000i 1.0000 + 2.4142i

MagX = 4.0000 2.6131 0.0000 1.0824 0.0000 1.0824 0.0000 2.6131


PhaseX = 0 -67.5000 -135.0000 -22.5000 -90.0000 22.5000 -45.0000 67.5000

3.5

2.5

1.5

0.5

0
0 1 2 3 4 5 6 7

PHASE PLOT 439


100

50

-50

-100

-150
0 1 2 3 4 5 6 7

RESULT: The DFT of given sequence is obtained. Hence the theory and practical value
are proved

DEPT. OF ECE, SVR ENGINEERING COLLEGE


DSP LAB III B.TECH I SEM
Sequence 439
1

0.8

Amplitude
0.6

0.4

0.2

0
0 1 2 3 4 5 6 7
Time Index n

Magnitude of the DFT sample 439


4

3
magnitude

0
0 1 2 3 4 5 6 7
Frequency Index K

Phase of DFT sample 439


2

1
Convolution

-1

-2
0 1 2 3 4 5 6 7
Frequency Index K

RESULT: - Thus Fast Fourier Transform is Performed using Matlab.

DEPT. OF ECE, SVR ENGINEERING COLLEGE


DSP LAB III B.TECH I SEM
Sequence 439
4

Amplitude
2

0
0 1 2 3 4 5 6 7
Time Index n

Magnitude of the IFFT sample 439


2.5

2
magnitude

1.5

0.5

0
0 1 2 3 4 5 6 7
Frequency Index K

Phase of IFFT sample 439


4

2
Phase

-2

-4
0 1 2 3 4 5 6 7
Frequency Index K

DEPT. OF ECE, SVR ENGINEERING COLLEGE


DSP LAB III B.TECH I SEM

RESULT: -- Analog filters using Matlab is designed.

DEPT. OF ECE, SVR ENGINEERING COLLEGE


DSP LAB III B.TECH I SEM
[n,wn]=cheb1ord(wp,ws,rp,rs);
[b,a]=cheby1(n,rp,wn, 'high');
[h,w]=freqz(b,a,128);

subplot(1,2,2);
plot(abs(h));
xlabel('frequency');
ylabel('amplitude');
title('high pass chebyshev filter response')

Output :

439 439

RESULT : Design and implementation of iir chebyshev (lp/hp) filter using matlab is verified.

VIVA QUESTION:

1. What do you mean by cut-off frequency?


2. Give the difference between analog and digital filter?
3. What is the difference between type 1 and type 2 filter structure?
4. what is the role of delay element in filter design?
5. Explain how the frequency is filter in filters?
6. Differences between Butterworth chebyshev filters?
7. Can IIR filters be Linear phase? how to make it linear Phase?

DEPT. OF ECE, SVR ENGINEERING COLLEGE


OUTPUT:-

enter passband ripple0.02


enter the stopband ripple0.01
enter passband freq1000
enter stopband freq2000
enter sampling freq 10000
enter beta value0.2

enter your choice of window function 1. rectangular 2. Hamming 3.kaiser:


2
Hamming window filter response

HPF 439
0

-5

-10
Gain in dB-->

-15

-20

-25
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
(b) Normalized frequency-->
subplot(2,2,4);

plot(o/pi,m,'r');
title('band stop filter');

ylabel('gain in db'); xlabel('(d) normalised frequency');

OUTPUT :

Blue color- Kaiser Window, Red color-Rectangular window

439 439

439 439

439 439

439 439
ylabel('Gain in dB-->');

subplot(2,1,2);plot(om/pi,an);

title('phase response of IIR filter is:');

xlabel('(b) Normalized freq. -->');

ylabel('Phase in radians-->');

OUTPUT :--
enter the IIR filter design specifications

enter the passband ripple.5

enter the stopband ripple.8

enter the passband freq1000

enter the stopband freq2000

enter the sampling freq3000

enter choice of filter 1. LPF 2. HPF

Frequency response of IIR LPF is:

439

439
Enter Down Sampling Factor:3
Enter Number of Samples:100

Input Sequence 439


2

1
Amplitude

-1

-2
0 10 20 30 40 50 60 70 80 90 100
Time Index n
Output Sequence 439
2

1
Amplitude

-1

-2
0 5 10 15 20 25 30 35
Time Index n

PROGRAM: Interpolation
clc;
clear all;
close all;
L=input('Up Sampling Factor:');
N=input('Enter Number of Samples:');
n=0:N-1;
x=sin(2*pi*0.043*n)+sin(2*pi*0.031*n);
y=interp(x,L);
subplot(2,1,1);
stem(n,x(1:N));
title('Input Sequence');
xlabel('Time Index n');
ylabel('Amplitude');
subplot(2,1,2);
m=0:(N*L)-1;
stem(m,y(1:N*L));
title('Output Sequence');
xlabel('Time Index n');
ylabel('Amplitude');
OUTPUT :
Up Sampling Factor:3
Enter Number of Samples:100
Input Sequence 439
2

Amplitude 1

-1

-2
0 10 20 30 40 50 60 70 80 90 100
Time Index n
Output Sequence 439
2

1
Amplitude

-1

-2
0 50 100 150 200 250 300
Time Index n

You might also like