DSP Practical File

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Department of Electronic Science

SRI VENKATESWARA COLLEGE


UNIVERSITY OF DELHI
DHAULA KUAN, NEW DELHI

DIGITAL SIGNAL PROCESSING


PRACTICAL FILE

Name: Deepanshi Singh


Roll Number: 1621012
Course: B.Sc.(H) Electronics
Sem: V
INDEX
S.No. Experiment
1 Generation of different types of
sequences and signals
2 Generate and plot sequences over an
interval

3 Fourier transform, discrete fourier


transform, fast fourier transform of a
given signal
4 Z Transform
5 Design an RC Low pass Filter in
Simulink
6 Design an RC High pass Filter in
Simulink
Experiment 1
1)Unit Step Sequence
n=[n1:n2];
x=[(n-n0)>=0];
stem(n,x,':xr');

2)Unit Impulse Sequence


n=[n1:0.001:n2];
x=[(n-n0)==0];
plot(n,x);
3)Unit Ramp Sequence
n=[n1:n2];
x=n.*[n >= 0];
stem(n,x,':xr');

4)Unit Ramp Signal


n=[n1:0.01:n2];
x=n.*[n >= 0];
plot(n,x);
5)Sinusoidal sequence
n=[n1:n2];
x=[sin(n)];
stem(n,x,':xr');

6)Sinusoidal Signal
y=sin(x);
subplot(3,1,1);
plot(x,y,'go-','MarkerSize', 1);
title('Original Signal');

y=sin(2*x);
subplot(3,1,2);
plot(x,y,'mo-','MarkerSize', 1);
title('Shrinked Signal');

y=sin(1/2*x);
subplot(3,1,3);
plot(x,y,'co-','MarkerSize', 1);
title('Expanded Signal');
7)Cosine Sequence
n=[n1:n2];
x=[cos(n)];
stem(n,x,':xr');
8)Cosine Signal
x=(n0:0.01:n1);
y=cos(x);
subplot(3,1,1);
plot(x,y,'go-','MarkerSize', 1);
title('Original Signal');
y=cos(2*x);
subplot(3,1,2);
plot(x,y,'mo-','MarkerSize', 1);
title('Shrinked Signal');
y=cos(1/2*x);
subplot(3,1,3);
plot(x,y,'co-','MarkerSize', 1);
title('Expanded Signal');
Experiment 2
Q1.
INPUT:
n=-5:5;
x=zeros(size(n));
x(n==2)=1;
x(n==3)=-1;
stem(n,x,'filled');
xlabel('n');
ylabel('x[n]');
title('impulse sequence x[n] =\delta[n-2]-\delta[n-3]');
grid on ;

OUTPUT:

Q2.
INPUT:
n=0:20;
x=zeros(size(n));
x(n>=0 &n<=10)=10*exp(-0.3*(n(n>=0&n<=10)-10));
x(n>=10 &n<=20)=-10*exp(-0.3*(n(n>=10&n<=20)-10));
stem(n,x,'filled');
xlabel('n');
ylabel('x[n]');
title('unit sequence x[n] =10e^(0.3(n-10)}u[n]-u[n-10])-10e^(-
0.3(n-10)}u[n-10]-u[n-20])');
grid on ;

OUTPUT:
Q3.
INPUT:
n=[0:200];
x=3*cos(0.04*pi*n);
stem(n,x,'filled');
xlabel('n');
ylabel('x[n]');
title('');
grid on ;

OUTPUT:

Q4.
INPUT:
n=[-30:29];
x=[1:10];
xtilde =x'*ones(1,6);
xtilde =(xtilde(:))';
stem(n,xtilde);
title('Peroidical Sequence');
xlabel('n');
ylabel('x[n]');
OUTPUT:

Q5.
INPUT:
x=[1,2,3,4,5,6,7,6,5,4,3,2,1];
n=-6:6;
x1=zeros(size(n));
for i=1:length(n)
if (i-5>=1)&&(i+4<=length(n))
x1(i)=2*x(i-5)-3*x(i+4);
end
end

stem(n,x1,'filled');
xlabel('n');
ylabel('x1[n]');
title('Plot the sequence');
grid on ;

OUTPUT:
Q6.
INPUT:
n = [-30:1:30];
alpha = -0.05+0.3j;
x = exp(alpha*n);
subplot(2,2,1);
stem(n,real(x));
title('Real part');
xlabel('n')
subplot(2,2,2);
stem(n,imag(x));
title('Imaginary part');
xlabel('n')
subplot(2,2,3);
stem(n,abs(x));
title('Magnitude');
xlabel('n')
subplot(2,2,4);
stem(n,(180/pi)*angle(x));
title('Phase');
xlabel('n')

OUTPUT:

Q7.
INPUT:
n=-5:5;
x=zeros(size(n));
u(n>=0)=1;
stem(n,u,'filled');
xlabel('n');
ylabel('u[n]');
title('unit step sequence u[n]');
grid on ;
n = [0:10];
x = stepseq(0,0,10)- stepseq(10,0,10);
[xe,xo,m] = evenodd(x,n);
subplot(2,2,1); stem(n,x); title('Rectangular pulse')
xlabel('n'); ylabel('x(n)'); axis([-10,10,0,1.2])
subplot(2,2,2); stem(m,xe); title('Even Part')
xlabel('n'); ylabel('xe(n)'); axis([-10,10,0,1.2])
subplot(2,2,4); stem(m,xo); title('Odd Part')
xlabel('n'); ylabel('xe(n)'); axis([-10,10,-0.6,0.6])

OUTPUT:
Experiment 3
a)
syms w
nval = [1 2 3 2 1];
interval = -2:2;
X(w) = sum(nval.*exp(-1j*w*interval))
w = [0 2*pi];
subs(X(w));
mag = abs(X(w))
ang = angle(X(w))
figure
plot(subplot(211),abs(X(w)),[0 2*pi]), grid,
ylabel('Magnitude'), ylim([0 5])
plot(subplot(212),angle(X(w)),[0 2*pi]), grid,
ylabel('Phase (rad)'), xlabel('w (rad)')
b)
n = 0:1/100:10-1/100;
x = (0.5).^(n+2);
y = fft(x)
m = abs(y);
y(m<1e-6) = 0;
p = unwrap(angle(y));
f = (0:length(y)-1)*100/length(y);
subplot(2,1,1)
plot(f,m)
title('Magnitude')
subplot(2,1,2)
plot(f,p*180/pi)
title('Phase')

C)
n = 0:1/100:10-1/100;
x = n.*(0.5).^(2*n)
y = fft(x);
m = abs(y);
y(m<1e-6) = 0;
p = unwrap(angle(y));
f = (0:length(y)-1)*100/length(y);
subplot(2,1,1)
plot(f,m)
title('Magnitude')
subplot(2,1,2)
plot(f,p*180/pi)
title('Phase')
Experiment 4
Q1
syms k z
f = kroneckerDelta(k);
f_z = ztrans(f, z)

Q2
syms a n z
f = a^n;
f_z = ztrans(f, z)
pretty(f_z)

Q3
syms b n z
f = -(5)^n;
f_z = ztrans(f, z);
pretty(f_z)
Q4
syms n z
f = n;
f_z = ztrans(f, z)
pretty(f_z)

Q5
syms a n z
f1 = a^n;
f2 = n;
f_z = ztrans([f1*f2], z)
pretty(f_z)
Q6
syms n z w
f = sin(w*n);
f_z = ztrans(f, z)

Q7
syms n z w
f = cos(w*n);
f_z = ztrans(f, z)
Experiment 5
Design an RC Low pass Filter in Simulink

At Cutoff Frequency:

Below Cutoff Frequency:


Above Cutoff Frequency:
Experiment 6
Design an RC High pass Filter in Simulink

At Cutoff Frequency:
Below Cutoff Frequency:

Above Cutoff Frequency:

You might also like